use ::c2rust_bitfields;
use ::libc;
extern "C" {
    pub type re_dfa_t;
    pub type event_base;
    pub type evbuffer;
    pub type bufferevent_ops;
    pub type args;
    pub type tmuxpeer;
    pub type hyperlinks;
    pub type screen_write_cline;
    pub type screen_sel;
    pub type screen_titles;
    pub type environ;
    pub type options;
    pub type cmdq_item;
    pub type paste_buffer;
    pub type input_ctx;
    pub type cmds;
    pub type tty_key;
    pub type tty_code;
    pub type job;
    pub type control_state;
    pub type cmdq_list;
    pub type options_entry;
    fn getuid() -> __uid_t;
    fn getpid() -> __pid_t;
    fn gethostname(__name: *mut libc::c_char, __len: size_t) -> libc::c_int;
    fn __ctype_b_loc() -> *mut *const libc::c_ushort;
    fn fnmatch(
        __pattern: *const libc::c_char,
        __name: *const libc::c_char,
        __flags: libc::c_int,
    ) -> libc::c_int;
    fn dirname(__path: *mut libc::c_char) -> *mut libc::c_char;
    fn __xpg_basename(__path: *mut libc::c_char) -> *mut libc::c_char;
    fn fabs(_: libc::c_double) -> libc::c_double;
    fn fmod(_: libc::c_double, _: libc::c_double) -> libc::c_double;
    fn getpwuid(__uid: __uid_t) -> *mut passwd;
    fn regcomp(
        __preg: *mut regex_t,
        __pattern: *const libc::c_char,
        __cflags: libc::c_int,
    ) -> libc::c_int;
    fn regexec(
        __preg: *const regex_t,
        __String: *const libc::c_char,
        __nmatch: size_t,
        __pmatch: *mut regmatch_t,
        __eflags: libc::c_int,
    ) -> libc::c_int;
    fn regfree(__preg: *mut regex_t);
    fn strtod(_: *const libc::c_char, _: *mut *mut libc::c_char) -> libc::c_double;
    fn free(_: *mut libc::c_void);
    fn bsearch(
        __key: *const libc::c_void,
        __base: *const libc::c_void,
        __nmemb: size_t,
        __size: size_t,
        __compar: __compar_fn_t,
    ) -> *mut libc::c_void;
    fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void;
    fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void;
    fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> libc::c_int;
    fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
    fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
    fn strcspn(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_ulong;
    fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char;
    fn strlen(_: *const libc::c_char) -> libc::c_ulong;
    fn time(__timer: *mut time_t) -> time_t;
    fn strftime(
        __s: *mut libc::c_char,
        __maxsize: size_t,
        __format: *const libc::c_char,
        __tp: *const tm,
    ) -> size_t;
    fn localtime_r(__timer: *const time_t, __tp: *mut tm) -> *mut tm;
    fn ctime_r(__timer: *const time_t, __buf: *mut libc::c_char) -> *mut libc::c_char;
    fn evbuffer_new() -> *mut evbuffer;
    fn evbuffer_free(buf: *mut evbuffer);
    fn evbuffer_get_length(buf: *const evbuffer) -> size_t;
    fn evbuffer_add(buf: *mut evbuffer, data: *const libc::c_void, datlen: size_t) -> libc::c_int;
    fn evbuffer_add_printf(buf: *mut evbuffer, fmt: *const libc::c_char, _: ...) -> libc::c_int;
    fn evbuffer_pullup(buf: *mut evbuffer, size: ssize_t) -> *mut libc::c_uchar;
    fn evbuffer_readline(buffer: *mut evbuffer) -> *mut libc::c_char;
    fn strtonum(
        _: *const libc::c_char,
        _: libc::c_longlong,
        _: libc::c_longlong,
        _: *mut *const libc::c_char,
    ) -> libc::c_longlong;
    fn strlcat(_: *mut libc::c_char, _: *const libc::c_char, _: size_t) -> size_t;
    fn xmalloc(_: size_t) -> *mut libc::c_void;
    fn xcalloc(_: size_t, _: size_t) -> *mut libc::c_void;
    fn xrealloc(_: *mut libc::c_void, _: size_t) -> *mut libc::c_void;
    fn xreallocarray(_: *mut libc::c_void, _: size_t, _: size_t) -> *mut libc::c_void;
    fn xstrdup(_: *const libc::c_char) -> *mut libc::c_char;
    fn xstrndup(_: *const libc::c_char, _: size_t) -> *mut libc::c_char;
    fn xasprintf(_: *mut *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int;
    fn xvasprintf(
        _: *mut *mut libc::c_char,
        _: *const libc::c_char,
        _: ::core::ffi::VaList,
    ) -> libc::c_int;
    fn xsnprintf(_: *mut libc::c_char, _: size_t, _: *const libc::c_char, _: ...) -> libc::c_int;
    static mut global_options: *mut options;
    static mut global_s_options: *mut options;
    static mut global_w_options: *mut options;
    static mut global_environ: *mut environ;
    static mut start_time: timeval;
    static mut socket_path: *const libc::c_char;
    fn sig2name(_: libc::c_int) -> *const libc::c_char;
    fn getversion() -> *const libc::c_char;
    fn proc_get_peer_uid(_: *mut tmuxpeer) -> uid_t;
    static mut cfg_files: *mut *mut libc::c_char;
    static mut cfg_nfiles: u_int;
    fn paste_buffer_name(_: *mut paste_buffer) -> *const libc::c_char;
    fn paste_buffer_created(_: *mut paste_buffer) -> time_t;
    fn paste_buffer_data(_: *mut paste_buffer, _: *mut size_t) -> *const libc::c_char;
    fn paste_get_top(_: *mut *const libc::c_char) -> *mut paste_buffer;
    fn paste_make_sample(_: *mut paste_buffer) -> *mut libc::c_char;
    fn job_free(_: *mut job);
    fn cmdq_get_event(_: *mut cmdq_item) -> *mut key_event;
    fn cmdq_merge_formats(_: *mut cmdq_item, _: *mut format_tree);
    fn tty_window_offset(
        _: *mut tty,
        _: *mut u_int,
        _: *mut u_int,
        _: *mut u_int,
        _: *mut u_int,
    ) -> libc::c_int;
    fn options_get_number(_: *mut options, _: *const libc::c_char) -> libc::c_longlong;
    fn cmd_stringify_argv(_: libc::c_int, _: *mut *mut libc::c_char) -> *mut libc::c_char;
    fn tty_default_colours(_: *mut grid_cell, _: *mut window_pane);
    fn cmd_mouse_at(
        _: *mut window_pane,
        _: *mut mouse_event,
        _: *mut u_int,
        _: *mut u_int,
        _: libc::c_int,
    ) -> libc::c_int;
    fn cmd_mouse_pane(
        _: *mut mouse_event,
        _: *mut *mut session,
        _: *mut *mut winlink,
    ) -> *mut window_pane;
    fn options_get_string(_: *mut options, _: *const libc::c_char) -> *const libc::c_char;
    fn tty_get_features(_: libc::c_int) -> *const libc::c_char;
    fn cmdq_print(_: *mut cmdq_item, _: *const libc::c_char, _: ...);
    fn cmd_free_argv(_: libc::c_int, _: *mut *mut libc::c_char);
    fn format_width(_: *const libc::c_char) -> u_int;
    fn format_trim_right(_: *const libc::c_char, _: u_int) -> *mut libc::c_char;
    fn format_trim_left(_: *const libc::c_char, _: u_int) -> *mut libc::c_char;
    fn environ_find(_: *mut environ, _: *const libc::c_char) -> *mut environ_entry;
    fn options_to_string(
        _: *mut options_entry,
        _: libc::c_int,
        _: libc::c_int,
    ) -> *mut libc::c_char;
    fn options_parse_get(
        _: *mut options,
        _: *const libc::c_char,
        _: *mut libc::c_int,
        _: libc::c_int,
    ) -> *mut options_entry;
    fn job_get_data(_: *mut job) -> *mut libc::c_void;
    fn job_get_event(_: *mut job) -> *mut bufferevent;
    fn cmdq_get_target_client(_: *mut cmdq_item) -> *mut client;
    fn cmdq_get_target(_: *mut cmdq_item) -> *mut cmd_find_state;
    fn job_run(
        _: *const libc::c_char,
        _: libc::c_int,
        _: *mut *mut libc::c_char,
        _: *mut environ,
        _: *mut session,
        _: *const libc::c_char,
        _: job_update_cb,
        _: job_complete_cb,
        _: job_free_cb,
        _: *mut libc::c_void,
        _: libc::c_int,
        _: libc::c_int,
        _: libc::c_int,
    ) -> *mut job;
    fn cmdq_get_client(_: *mut cmdq_item) -> *mut client;
    static mut clients: clients;
    fn server_client_unref(_: *mut client);
    fn server_client_get_cwd(_: *mut client, _: *mut session) -> *const libc::c_char;
    fn server_status_client(_: *mut client);
    fn colour_fromstring(s: *const libc::c_char) -> libc::c_int;
    fn colour_force_rgb(_: libc::c_int) -> libc::c_int;
    fn window_pane_search(
        _: *mut window_pane,
        _: *const libc::c_char,
        _: libc::c_int,
        _: libc::c_int,
    ) -> u_int;
    fn server_client_get_flags(_: *mut client) -> *const libc::c_char;
    fn server_client_get_key_table(_: *mut client) -> *const libc::c_char;
    fn grid_view_get_cell(_: *mut grid, _: u_int, _: u_int, _: *mut grid_cell);
    fn grid_get_line(_: *mut grid, _: u_int) -> *mut grid_line;
    fn status_get_range(_: *mut client, _: u_int, _: u_int) -> *mut style_range;
    fn window_pane_mode(_: *mut window_pane) -> libc::c_int;
    fn grid_line_length(_: *mut grid, _: u_int) -> u_int;
    fn grid_peek_line(_: *mut grid, _: u_int) -> *const grid_line;
    fn grid_get_cell(_: *mut grid, _: u_int, _: u_int, _: *mut grid_cell);
    fn colour_tostring(_: libc::c_int) -> *const libc::c_char;
    fn window_pane_index(_: *mut window_pane, _: *mut u_int) -> libc::c_int;
    fn winlinks_RB_NEXT(_: *mut winlink) -> *mut winlink;
    fn winlink_count(_: *mut winlinks) -> u_int;
    fn server_check_marked() -> libc::c_int;
    static mut marked_pane: cmd_find_state;
    fn window_count_panes(_: *mut window) -> u_int;
    fn window_printable_flags(_: *mut winlink, _: libc::c_int) -> *const libc::c_char;
    fn winlinks_RB_MINMAX(_: *mut winlinks, _: libc::c_int) -> *mut winlink;
    fn utf8_padcstr(_: *const libc::c_char, _: u_int) -> *mut libc::c_char;
    fn utf8_rpadcstr(_: *const libc::c_char, _: u_int) -> *mut libc::c_char;
    static window_buffer_mode: window_mode;
    fn session_alive(_: *mut session) -> libc::c_int;
    static window_client_mode: window_mode;
    fn window_copy_get_line(_: *mut window_pane, _: u_int) -> *mut libc::c_char;
    fn utf8_set(_: *mut utf8_data, _: u_char);
    fn window_copy_get_word(_: *mut window_pane, _: u_int, _: u_int) -> *mut libc::c_char;
    fn utf8_cstrhas(_: *const libc::c_char, _: *const utf8_data) -> libc::c_int;
    fn utf8_tocstr(_: *mut utf8_data) -> *mut libc::c_char;
    static mut next_session_id: u_int;
    fn osdep_get_name(_: libc::c_int, _: *mut libc::c_char) -> *mut libc::c_char;
    fn parse_window_name(_: *const libc::c_char) -> *mut libc::c_char;
    fn osdep_get_cwd(_: libc::c_int) -> *mut libc::c_char;
    fn layout_dump(_: *mut layout_cell) -> *mut libc::c_char;
    fn session_is_linked(_: *mut session, _: *mut window) -> libc::c_int;
    fn sessions_RB_MINMAX(_: *mut sessions, _: libc::c_int) -> *mut session;
    static mut sessions: sessions;
    fn sessions_RB_NEXT(_: *mut session) -> *mut session;
    fn session_group_attached_count(_: *mut session_group) -> u_int;
    fn session_group_count(_: *mut session_group) -> u_int;
    fn session_group_contains(_: *mut session) -> *mut session_group;
    static window_tree_mode: window_mode;
    fn log_get_level() -> libc::c_int;
    fn log_debug(_: *const libc::c_char, _: ...);
    fn fatalx(_: *const libc::c_char, _: ...) -> !;
    fn regsub(
        _: *const libc::c_char,
        _: *const libc::c_char,
        _: *const libc::c_char,
        _: libc::c_int,
    ) -> *mut libc::c_char;
    fn hyperlinks_get(
        _: *mut hyperlinks,
        _: u_int,
        _: *mut *const libc::c_char,
        _: *mut *const libc::c_char,
        _: *mut *const libc::c_char,
    ) -> libc::c_int;
}
pub type __builtin_va_list = [__va_list_tag; 1];
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __va_list_tag {
    pub gp_offset: libc::c_uint,
    pub fp_offset: libc::c_uint,
    pub overflow_arg_area: *mut libc::c_void,
    pub reg_save_area: *mut libc::c_void,
}
pub type __u_char = libc::c_uchar;
pub type __u_short = libc::c_ushort;
pub type __u_int = libc::c_uint;
pub type __uint8_t = libc::c_uchar;
pub type __uint64_t = libc::c_ulong;
pub type __uid_t = libc::c_uint;
pub type __gid_t = libc::c_uint;
pub type __pid_t = libc::c_int;
pub type __time_t = libc::c_long;
pub type __suseconds_t = libc::c_long;
pub type __ssize_t = libc::c_long;
pub type u_char = __u_char;
pub type u_short = __u_short;
pub type u_int = __u_int;
pub type uid_t = __uid_t;
pub type pid_t = __pid_t;
pub type ssize_t = __ssize_t;
pub type time_t = __time_t;
pub type size_t = libc::c_ulong;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timeval {
    pub tv_sec: __time_t,
    pub tv_usec: __suseconds_t,
}
pub type C2RustUnnamed = libc::c_uint;
pub const _ISalnum: C2RustUnnamed = 8;
pub const _ISpunct: C2RustUnnamed = 4;
pub const _IScntrl: C2RustUnnamed = 2;
pub const _ISblank: C2RustUnnamed = 1;
pub const _ISgraph: C2RustUnnamed = 32768;
pub const _ISprint: C2RustUnnamed = 16384;
pub const _ISspace: C2RustUnnamed = 8192;
pub const _ISxdigit: C2RustUnnamed = 4096;
pub const _ISdigit: C2RustUnnamed = 2048;
pub const _ISalpha: C2RustUnnamed = 1024;
pub const _ISlower: C2RustUnnamed = 512;
pub const _ISupper: C2RustUnnamed = 256;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct passwd {
    pub pw_name: *mut libc::c_char,
    pub pw_passwd: *mut libc::c_char,
    pub pw_uid: __uid_t,
    pub pw_gid: __gid_t,
    pub pw_gecos: *mut libc::c_char,
    pub pw_dir: *mut libc::c_char,
    pub pw_shell: *mut libc::c_char,
}
pub type __re_long_size_t = libc::c_ulong;
pub type reg_syntax_t = libc::c_ulong;
#[derive(Copy, Clone, BitfieldStruct)]
#[repr(C)]
pub struct re_pattern_buffer {
    pub buffer: *mut re_dfa_t,
    pub allocated: __re_long_size_t,
    pub used: __re_long_size_t,
    pub syntax: reg_syntax_t,
    pub fastmap: *mut libc::c_char,
    pub translate: *mut libc::c_uchar,
    pub re_nsub: size_t,
    #[bitfield(name = "can_be_null", ty = "libc::c_uint", bits = "0..=0")]
    #[bitfield(name = "regs_allocated", ty = "libc::c_uint", bits = "1..=2")]
    #[bitfield(name = "fastmap_accurate", ty = "libc::c_uint", bits = "3..=3")]
    #[bitfield(name = "no_sub", ty = "libc::c_uint", bits = "4..=4")]
    #[bitfield(name = "not_bol", ty = "libc::c_uint", bits = "5..=5")]
    #[bitfield(name = "not_eol", ty = "libc::c_uint", bits = "6..=6")]
    #[bitfield(name = "newline_anchor", ty = "libc::c_uint", bits = "7..=7")]
    pub can_be_null_regs_allocated_fastmap_accurate_no_sub_not_bol_not_eol_newline_anchor: [u8; 1],
    #[bitfield(padding)]
    pub c2rust_padding: [u8; 7],
}
pub type regex_t = re_pattern_buffer;
pub type regoff_t = libc::c_int;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct regmatch_t {
    pub rm_so: regoff_t,
    pub rm_eo: regoff_t,
}
pub type va_list = __builtin_va_list;
pub type __compar_fn_t =
    Option<unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tm {
    pub tm_sec: libc::c_int,
    pub tm_min: libc::c_int,
    pub tm_hour: libc::c_int,
    pub tm_mday: libc::c_int,
    pub tm_mon: libc::c_int,
    pub tm_year: libc::c_int,
    pub tm_wday: libc::c_int,
    pub tm_yday: libc::c_int,
    pub tm_isdst: libc::c_int,
    pub tm_gmtoff: libc::c_long,
    pub tm_zone: *const libc::c_char,
}
pub type cc_t = libc::c_uchar;
pub type speed_t = libc::c_uint;
pub type tcflag_t = libc::c_uint;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct termios {
    pub c_iflag: tcflag_t,
    pub c_oflag: tcflag_t,
    pub c_cflag: tcflag_t,
    pub c_lflag: tcflag_t,
    pub c_line: cc_t,
    pub c_cc: [cc_t; 32],
    pub c_ispeed: speed_t,
    pub c_ospeed: speed_t,
}
pub type uint8_t = __uint8_t;
pub type uint64_t = __uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event {
    pub ev_evcallback: event_callback,
    pub ev_timeout_pos: C2RustUnnamed_5,
    pub ev_fd: libc::c_int,
    pub ev_base: *mut event_base,
    pub ev_: C2RustUnnamed_0,
    pub ev_events: libc::c_short,
    pub ev_res: libc::c_short,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_0 {
    pub ev_io: C2RustUnnamed_3,
    pub ev_signal: C2RustUnnamed_1,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_1 {
    pub ev_signal_next: C2RustUnnamed_2,
    pub ev_ncalls: libc::c_short,
    pub ev_pncalls: *mut libc::c_short,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_2 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_3 {
    pub ev_io_next: C2RustUnnamed_4,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_4 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_5 {
    pub ev_next_with_common_timeout: C2RustUnnamed_6,
    pub min_heap_idx: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_6 {
    pub tqe_next: *mut event,
    pub tqe_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_callback {
    pub evcb_active_next: C2RustUnnamed_8,
    pub evcb_flags: libc::c_short,
    pub evcb_pri: uint8_t,
    pub evcb_closure: uint8_t,
    pub evcb_cb_union: C2RustUnnamed_7,
    pub evcb_arg: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_7 {
    pub evcb_callback:
        Option<unsafe extern "C" fn(libc::c_int, libc::c_short, *mut libc::c_void) -> ()>,
    pub evcb_selfcb: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
    pub evcb_evfinalize: Option<unsafe extern "C" fn(*mut event, *mut libc::c_void) -> ()>,
    pub evcb_cbfinalize: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_8 {
    pub tqe_next: *mut event_callback,
    pub tqe_prev: *mut *mut event_callback,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct bufferevent {
    pub ev_base: *mut event_base,
    pub be_ops: *const bufferevent_ops,
    pub ev_read: event,
    pub ev_write: event,
    pub input: *mut evbuffer,
    pub output: *mut evbuffer,
    pub wm_read: event_watermark,
    pub wm_write: event_watermark,
    pub readcb: bufferevent_data_cb,
    pub writecb: bufferevent_data_cb,
    pub errorcb: bufferevent_event_cb,
    pub cbarg: *mut libc::c_void,
    pub timeout_read: timeval,
    pub timeout_write: timeval,
    pub enabled: libc::c_short,
}
pub type bufferevent_event_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, libc::c_short, *mut libc::c_void) -> ()>;
pub type bufferevent_data_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, *mut libc::c_void) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_watermark {
    pub low: size_t,
    pub high: size_t,
}
pub type bitstr_t = libc::c_uchar;
pub type msgtype = libc::c_uint;
pub const MSG_READ_CANCEL: msgtype = 307;
pub const MSG_WRITE_CLOSE: msgtype = 306;
pub const MSG_WRITE_READY: msgtype = 305;
pub const MSG_WRITE: msgtype = 304;
pub const MSG_WRITE_OPEN: msgtype = 303;
pub const MSG_READ_DONE: msgtype = 302;
pub const MSG_READ: msgtype = 301;
pub const MSG_READ_OPEN: msgtype = 300;
pub const MSG_FLAGS: msgtype = 218;
pub const MSG_EXEC: msgtype = 217;
pub const MSG_WAKEUP: msgtype = 216;
pub const MSG_UNLOCK: msgtype = 215;
pub const MSG_SUSPEND: msgtype = 214;
pub const MSG_OLDSTDOUT: msgtype = 213;
pub const MSG_OLDSTDIN: msgtype = 212;
pub const MSG_OLDSTDERR: msgtype = 211;
pub const MSG_SHUTDOWN: msgtype = 210;
pub const MSG_SHELL: msgtype = 209;
pub const MSG_RESIZE: msgtype = 208;
pub const MSG_READY: msgtype = 207;
pub const MSG_LOCK: msgtype = 206;
pub const MSG_EXITING: msgtype = 205;
pub const MSG_EXITED: msgtype = 204;
pub const MSG_EXIT: msgtype = 203;
pub const MSG_DETACHKILL: msgtype = 202;
pub const MSG_DETACH: msgtype = 201;
pub const MSG_COMMAND: msgtype = 200;
pub const MSG_IDENTIFY_TERMINFO: msgtype = 112;
pub const MSG_IDENTIFY_LONGFLAGS: msgtype = 111;
pub const MSG_IDENTIFY_STDOUT: msgtype = 110;
pub const MSG_IDENTIFY_FEATURES: msgtype = 109;
pub const MSG_IDENTIFY_CWD: msgtype = 108;
pub const MSG_IDENTIFY_CLIENTPID: msgtype = 107;
pub const MSG_IDENTIFY_DONE: msgtype = 106;
pub const MSG_IDENTIFY_ENVIRON: msgtype = 105;
pub const MSG_IDENTIFY_STDIN: msgtype = 104;
pub const MSG_IDENTIFY_OLDCWD: msgtype = 103;
pub const MSG_IDENTIFY_TTYNAME: msgtype = 102;
pub const MSG_IDENTIFY_TERM: msgtype = 101;
pub const MSG_IDENTIFY_FLAGS: msgtype = 100;
pub const MSG_VERSION: msgtype = 12;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client {
    pub name: *const libc::c_char,
    pub peer: *mut tmuxpeer,
    pub queue: *mut cmdq_list,
    pub windows: client_windows,
    pub control_state: *mut control_state,
    pub pause_age: u_int,
    pub pid: pid_t,
    pub fd: libc::c_int,
    pub out_fd: libc::c_int,
    pub event: event,
    pub retval: libc::c_int,
    pub creation_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub environ: *mut environ,
    pub jobs: *mut format_job_tree,
    pub title: *mut libc::c_char,
    pub path: *mut libc::c_char,
    pub cwd: *const libc::c_char,
    pub term_name: *mut libc::c_char,
    pub term_features: libc::c_int,
    pub term_type: *mut libc::c_char,
    pub term_caps: *mut *mut libc::c_char,
    pub term_ncaps: u_int,
    pub ttyname: *mut libc::c_char,
    pub tty: tty,
    pub written: size_t,
    pub discarded: size_t,
    pub redraw: size_t,
    pub repeat_timer: event,
    pub click_timer: event,
    pub click_button: u_int,
    pub click_event: mouse_event,
    pub status: status_line,
    pub flags: uint64_t,
    pub exit_type: C2RustUnnamed_32,
    pub exit_msgtype: msgtype,
    pub exit_session: *mut libc::c_char,
    pub exit_message: *mut libc::c_char,
    pub keytable: *mut key_table,
    pub last_key: key_code,
    pub redraw_panes: uint64_t,
    pub redraw_scrollbars: uint64_t,
    pub message_ignore_keys: libc::c_int,
    pub message_ignore_styles: libc::c_int,
    pub message_string: *mut libc::c_char,
    pub message_timer: event,
    pub prompt_string: *mut libc::c_char,
    pub prompt_buffer: *mut utf8_data,
    pub prompt_last: *mut libc::c_char,
    pub prompt_index: size_t,
    pub prompt_inputcb: prompt_input_cb,
    pub prompt_freecb: prompt_free_cb,
    pub prompt_data: *mut libc::c_void,
    pub prompt_hindex: [u_int; 4],
    pub prompt_mode: C2RustUnnamed_29,
    pub prompt_saved: *mut utf8_data,
    pub prompt_flags: libc::c_int,
    pub prompt_type: prompt_type,
    pub prompt_cursor: libc::c_int,
    pub session: *mut session,
    pub last_session: *mut session,
    pub references: libc::c_int,
    pub pan_window: *mut libc::c_void,
    pub pan_ox: u_int,
    pub pan_oy: u_int,
    pub overlay_check: overlay_check_cb,
    pub overlay_mode: overlay_mode_cb,
    pub overlay_draw: overlay_draw_cb,
    pub overlay_key: overlay_key_cb,
    pub overlay_free: overlay_free_cb,
    pub overlay_resize: overlay_resize_cb,
    pub overlay_data: *mut libc::c_void,
    pub overlay_timer: event,
    pub files: client_files,
    pub clipboard_panes: *mut u_int,
    pub clipboard_npanes: u_int,
    pub entry: C2RustUnnamed_9,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_9 {
    pub tqe_next: *mut client,
    pub tqe_prev: *mut *mut client,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_files {
    pub rbh_root: *mut client_file,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_file {
    pub c: *mut client,
    pub peer: *mut tmuxpeer,
    pub tree: *mut client_files,
    pub references: libc::c_int,
    pub stream: libc::c_int,
    pub path: *mut libc::c_char,
    pub buffer: *mut evbuffer,
    pub event: *mut bufferevent,
    pub fd: libc::c_int,
    pub error: libc::c_int,
    pub closed: libc::c_int,
    pub cb: client_file_cb,
    pub data: *mut libc::c_void,
    pub entry: C2RustUnnamed_10,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_10 {
    pub rbe_left: *mut client_file,
    pub rbe_right: *mut client_file,
    pub rbe_parent: *mut client_file,
    pub rbe_color: libc::c_int,
}
pub type client_file_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *const libc::c_char,
        libc::c_int,
        libc::c_int,
        *mut evbuffer,
        *mut libc::c_void,
    ) -> (),
>;
pub type overlay_resize_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_free_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_key_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut key_event) -> libc::c_int>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_event {
    pub key: key_code,
    pub m: mouse_event,
    pub buf: *mut libc::c_char,
    pub len: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mouse_event {
    pub valid: libc::c_int,
    pub ignore: libc::c_int,
    pub key: key_code,
    pub statusat: libc::c_int,
    pub statuslines: u_int,
    pub x: u_int,
    pub y: u_int,
    pub b: u_int,
    pub lx: u_int,
    pub ly: u_int,
    pub lb: u_int,
    pub ox: u_int,
    pub oy: u_int,
    pub s: libc::c_int,
    pub w: libc::c_int,
    pub wp: libc::c_int,
    pub sgr_type: u_int,
    pub sgr_b: u_int,
}
pub type key_code = libc::c_ulonglong;
pub type overlay_draw_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut screen_redraw_ctx) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen_redraw_ctx {
    pub c: *mut client,
    pub statuslines: u_int,
    pub statustop: libc::c_int,
    pub pane_status: libc::c_int,
    pub pane_lines: pane_lines,
    pub pane_scrollbars: libc::c_int,
    pub pane_scrollbars_pos: libc::c_int,
    pub no_pane_gc: grid_cell,
    pub no_pane_gc_set: libc::c_int,
    pub sx: u_int,
    pub sy: u_int,
    pub ox: u_int,
    pub oy: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_cell {
    pub data: utf8_data,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub us: libc::c_int,
    pub link: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct utf8_data {
    pub data: [u_char; 21],
    pub have: u_char,
    pub size: u_char,
    pub width: u_char,
}
pub type pane_lines = libc::c_uint;
pub const PANE_LINES_NUMBER: pane_lines = 4;
pub const PANE_LINES_SIMPLE: pane_lines = 3;
pub const PANE_LINES_HEAVY: pane_lines = 2;
pub const PANE_LINES_DOUBLE: pane_lines = 1;
pub const PANE_LINES_SINGLE: pane_lines = 0;
pub type overlay_mode_cb = Option<
    unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut u_int, *mut u_int) -> *mut screen,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen {
    pub title: *mut libc::c_char,
    pub path: *mut libc::c_char,
    pub titles: *mut screen_titles,
    pub grid: *mut grid,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub default_cstyle: screen_cursor_style,
    pub ccolour: libc::c_int,
    pub default_ccolour: libc::c_int,
    pub rupper: u_int,
    pub rlower: u_int,
    pub mode: libc::c_int,
    pub default_mode: libc::c_int,
    pub saved_cx: u_int,
    pub saved_cy: u_int,
    pub saved_grid: *mut grid,
    pub saved_cell: grid_cell,
    pub saved_flags: libc::c_int,
    pub tabs: *mut bitstr_t,
    pub sel: *mut screen_sel,
    pub write_list: *mut screen_write_cline,
    pub hyperlinks: *mut hyperlinks,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid {
    pub flags: libc::c_int,
    pub sx: u_int,
    pub sy: u_int,
    pub hscrolled: u_int,
    pub hsize: u_int,
    pub hlimit: u_int,
    pub linedata: *mut grid_line,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_line {
    pub celldata: *mut grid_cell_entry,
    pub cellused: u_int,
    pub cellsize: u_int,
    pub extddata: *mut grid_extd_entry,
    pub extdsize: u_int,
    pub flags: libc::c_int,
    pub time: time_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_extd_entry {
    pub data: utf8_char,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub us: libc::c_int,
    pub link: u_int,
}
pub type utf8_char = u_int;
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_cell_entry {
    pub c2rust_unnamed: C2RustUnnamed_11,
    pub flags: u_char,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_11 {
    pub offset: u_int,
    pub data: C2RustUnnamed_12,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_12 {
    pub attr: u_char,
    pub fg: u_char,
    pub bg: u_char,
    pub data: u_char,
}
pub type screen_cursor_style = libc::c_uint;
pub const SCREEN_CURSOR_BAR: screen_cursor_style = 3;
pub const SCREEN_CURSOR_UNDERLINE: screen_cursor_style = 2;
pub const SCREEN_CURSOR_BLOCK: screen_cursor_style = 1;
pub const SCREEN_CURSOR_DEFAULT: screen_cursor_style = 0;
pub type overlay_check_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *mut libc::c_void,
        u_int,
        u_int,
        u_int,
        *mut overlay_ranges,
    ) -> (),
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct overlay_ranges {
    pub px: [u_int; 3],
    pub nx: [u_int; 3],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct session {
    pub id: u_int,
    pub name: *mut libc::c_char,
    pub cwd: *const libc::c_char,
    pub creation_time: timeval,
    pub last_attached_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub lock_timer: event,
    pub curw: *mut winlink,
    pub lastw: winlink_stack,
    pub windows: winlinks,
    pub statusat: libc::c_int,
    pub statuslines: u_int,
    pub options: *mut options,
    pub flags: libc::c_int,
    pub attached: u_int,
    pub tio: *mut termios,
    pub environ: *mut environ,
    pub references: libc::c_int,
    pub gentry: C2RustUnnamed_14,
    pub entry: C2RustUnnamed_13,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_13 {
    pub rbe_left: *mut session,
    pub rbe_right: *mut session,
    pub rbe_parent: *mut session,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_14 {
    pub tqe_next: *mut session,
    pub tqe_prev: *mut *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlinks {
    pub rbh_root: *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink {
    pub idx: libc::c_int,
    pub session: *mut session,
    pub window: *mut window,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_17,
    pub wentry: C2RustUnnamed_16,
    pub sentry: C2RustUnnamed_15,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_15 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_16 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_17 {
    pub rbe_left: *mut winlink,
    pub rbe_right: *mut winlink,
    pub rbe_parent: *mut winlink,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window {
    pub id: u_int,
    pub latest: *mut libc::c_void,
    pub name: *mut libc::c_char,
    pub name_event: event,
    pub name_time: timeval,
    pub alerts_timer: event,
    pub offset_timer: event,
    pub activity_time: timeval,
    pub active: *mut window_pane,
    pub last_panes: window_panes,
    pub panes: window_panes,
    pub lastlayout: libc::c_int,
    pub layout_root: *mut layout_cell,
    pub saved_layout_root: *mut layout_cell,
    pub old_layout: *mut libc::c_char,
    pub sx: u_int,
    pub sy: u_int,
    pub manual_sx: u_int,
    pub manual_sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub new_sx: u_int,
    pub new_sy: u_int,
    pub new_xpixel: u_int,
    pub new_ypixel: u_int,
    pub fill_character: *mut utf8_data,
    pub flags: libc::c_int,
    pub alerts_queued: libc::c_int,
    pub alerts_entry: C2RustUnnamed_20,
    pub options: *mut options,
    pub references: u_int,
    pub winlinks: C2RustUnnamed_19,
    pub entry: C2RustUnnamed_18,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_18 {
    pub rbe_left: *mut window,
    pub rbe_right: *mut window,
    pub rbe_parent: *mut window,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_19 {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_20 {
    pub tqe_next: *mut window,
    pub tqe_prev: *mut *mut window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cell {
    pub type_0: layout_type,
    pub parent: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub wp: *mut window_pane,
    pub cells: layout_cells,
    pub entry: C2RustUnnamed_21,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_21 {
    pub tqe_next: *mut layout_cell,
    pub tqe_prev: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cells {
    pub tqh_first: *mut layout_cell,
    pub tqh_last: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane {
    pub id: u_int,
    pub active_point: u_int,
    pub window: *mut window,
    pub options: *mut options,
    pub layout_cell: *mut layout_cell,
    pub saved_layout_cell: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub flags: libc::c_int,
    pub sb_slider_y: u_int,
    pub sb_slider_h: u_int,
    pub argc: libc::c_int,
    pub argv: *mut *mut libc::c_char,
    pub shell: *mut libc::c_char,
    pub cwd: *mut libc::c_char,
    pub pid: pid_t,
    pub tty: [libc::c_char; 32],
    pub status: libc::c_int,
    pub dead_time: timeval,
    pub fd: libc::c_int,
    pub event: *mut bufferevent,
    pub offset: window_pane_offset,
    pub base_offset: size_t,
    pub resize_queue: window_pane_resizes,
    pub resize_timer: event,
    pub ictx: *mut input_ctx,
    pub cached_gc: grid_cell,
    pub cached_active_gc: grid_cell,
    pub palette: colour_palette,
    pub pipe_fd: libc::c_int,
    pub pipe_event: *mut bufferevent,
    pub pipe_offset: window_pane_offset,
    pub screen: *mut screen,
    pub base: screen,
    pub status_screen: screen,
    pub status_size: size_t,
    pub modes: C2RustUnnamed_25,
    pub searchstr: *mut libc::c_char,
    pub searchregex: libc::c_int,
    pub border_gc_set: libc::c_int,
    pub border_gc: grid_cell,
    pub control_bg: libc::c_int,
    pub control_fg: libc::c_int,
    pub scrollbar_style: style,
    pub entry: C2RustUnnamed_24,
    pub sentry: C2RustUnnamed_23,
    pub tree_entry: C2RustUnnamed_22,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_22 {
    pub rbe_left: *mut window_pane,
    pub rbe_right: *mut window_pane,
    pub rbe_parent: *mut window_pane,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_23 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_24 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style {
    pub gc: grid_cell,
    pub ignore: libc::c_int,
    pub fill: libc::c_int,
    pub align: style_align,
    pub list: style_list,
    pub range_type: style_range_type,
    pub range_argument: u_int,
    pub range_string: [libc::c_char; 16],
    pub width: libc::c_int,
    pub pad: libc::c_int,
    pub default_type: style_default_type,
}
pub type style_default_type = libc::c_uint;
pub const STYLE_DEFAULT_POP: style_default_type = 2;
pub const STYLE_DEFAULT_PUSH: style_default_type = 1;
pub const STYLE_DEFAULT_BASE: style_default_type = 0;
pub type style_range_type = libc::c_uint;
pub const STYLE_RANGE_USER: style_range_type = 6;
pub const STYLE_RANGE_SESSION: style_range_type = 5;
pub const STYLE_RANGE_WINDOW: style_range_type = 4;
pub const STYLE_RANGE_PANE: style_range_type = 3;
pub const STYLE_RANGE_RIGHT: style_range_type = 2;
pub const STYLE_RANGE_LEFT: style_range_type = 1;
pub const STYLE_RANGE_NONE: style_range_type = 0;
pub type style_list = libc::c_uint;
pub const STYLE_LIST_RIGHT_MARKER: style_list = 4;
pub const STYLE_LIST_LEFT_MARKER: style_list = 3;
pub const STYLE_LIST_FOCUS: style_list = 2;
pub const STYLE_LIST_ON: style_list = 1;
pub const STYLE_LIST_OFF: style_list = 0;
pub type style_align = libc::c_uint;
pub const STYLE_ALIGN_ABSOLUTE_CENTRE: style_align = 4;
pub const STYLE_ALIGN_RIGHT: style_align = 3;
pub const STYLE_ALIGN_CENTRE: style_align = 2;
pub const STYLE_ALIGN_LEFT: style_align = 1;
pub const STYLE_ALIGN_DEFAULT: style_align = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_25 {
    pub tqh_first: *mut window_mode_entry,
    pub tqh_last: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode_entry {
    pub wp: *mut window_pane,
    pub swp: *mut window_pane,
    pub mode: *const window_mode,
    pub data: *mut libc::c_void,
    pub screen: *mut screen,
    pub prefix: u_int,
    pub entry: C2RustUnnamed_26,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_26 {
    pub tqe_next: *mut window_mode_entry,
    pub tqe_prev: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode {
    pub name: *const libc::c_char,
    pub default_format: *const libc::c_char,
    pub init: Option<
        unsafe extern "C" fn(*mut window_mode_entry, *mut cmd_find_state, *mut args) -> *mut screen,
    >,
    pub free: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub resize: Option<unsafe extern "C" fn(*mut window_mode_entry, u_int, u_int) -> ()>,
    pub update: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub key: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            key_code,
            *mut mouse_event,
        ) -> (),
    >,
    pub key_table: Option<unsafe extern "C" fn(*mut window_mode_entry) -> *const libc::c_char>,
    pub command: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            *mut args,
            *mut mouse_event,
        ) -> (),
    >,
    pub formats: Option<unsafe extern "C" fn(*mut window_mode_entry, *mut format_tree) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_tree {
    pub type_0: format_type,
    pub c: *mut client,
    pub s: *mut session,
    pub wl: *mut winlink,
    pub w: *mut window,
    pub wp: *mut window_pane,
    pub pb: *mut paste_buffer,
    pub item: *mut cmdq_item,
    pub client: *mut client,
    pub flags: libc::c_int,
    pub tag: u_int,
    pub m: mouse_event,
    pub tree: format_entry_tree,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_entry_tree {
    pub rbh_root: *mut format_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_entry {
    pub key: *mut libc::c_char,
    pub value: *mut libc::c_char,
    pub time: time_t,
    pub cb: format_cb,
    pub entry: C2RustUnnamed_27,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_27 {
    pub rbe_left: *mut format_entry,
    pub rbe_right: *mut format_entry,
    pub rbe_parent: *mut format_entry,
    pub rbe_color: libc::c_int,
}
pub type format_cb = Option<unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void>;
pub type format_type = libc::c_uint;
pub const FORMAT_TYPE_PANE: format_type = 3;
pub const FORMAT_TYPE_WINDOW: format_type = 2;
pub const FORMAT_TYPE_SESSION: format_type = 1;
pub const FORMAT_TYPE_UNKNOWN: format_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_find_state {
    pub flags: libc::c_int,
    pub current: *mut cmd_find_state,
    pub s: *mut session,
    pub wl: *mut winlink,
    pub w: *mut window,
    pub wp: *mut window_pane,
    pub idx: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_offset {
    pub used: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct colour_palette {
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub palette: *mut libc::c_int,
    pub default_palette: *mut libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resizes {
    pub tqh_first: *mut window_pane_resize,
    pub tqh_last: *mut *mut window_pane_resize,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resize {
    pub sx: u_int,
    pub sy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub entry: C2RustUnnamed_28,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_28 {
    pub tqe_next: *mut window_pane_resize,
    pub tqe_prev: *mut *mut window_pane_resize,
}
pub type layout_type = libc::c_uint;
pub const LAYOUT_WINDOWPANE: layout_type = 2;
pub const LAYOUT_TOPBOTTOM: layout_type = 1;
pub const LAYOUT_LEFTRIGHT: layout_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_panes {
    pub tqh_first: *mut window_pane,
    pub tqh_last: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink_stack {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
pub type prompt_type = libc::c_uint;
pub const PROMPT_TYPE_INVALID: prompt_type = 255;
pub const PROMPT_TYPE_WINDOW_TARGET: prompt_type = 3;
pub const PROMPT_TYPE_TARGET: prompt_type = 2;
pub const PROMPT_TYPE_SEARCH: prompt_type = 1;
pub const PROMPT_TYPE_COMMAND: prompt_type = 0;
pub type C2RustUnnamed_29 = libc::c_uint;
pub const PROMPT_COMMAND: C2RustUnnamed_29 = 1;
pub const PROMPT_ENTRY: C2RustUnnamed_29 = 0;
pub type prompt_free_cb = Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
pub type prompt_input_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *mut libc::c_void,
        *const libc::c_char,
        libc::c_int,
    ) -> libc::c_int,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_table {
    pub name: *const libc::c_char,
    pub activity_time: timeval,
    pub key_bindings: key_bindings,
    pub default_key_bindings: key_bindings,
    pub references: u_int,
    pub entry: C2RustUnnamed_30,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_30 {
    pub rbe_left: *mut key_table,
    pub rbe_right: *mut key_table,
    pub rbe_parent: *mut key_table,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_bindings {
    pub rbh_root: *mut key_binding,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_binding {
    pub key: key_code,
    pub cmdlist: *mut cmd_list,
    pub note: *const libc::c_char,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_31,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_31 {
    pub rbe_left: *mut key_binding,
    pub rbe_right: *mut key_binding,
    pub rbe_parent: *mut key_binding,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_list {
    pub references: libc::c_int,
    pub group: u_int,
    pub list: *mut cmds,
}
pub type C2RustUnnamed_32 = libc::c_uint;
pub const CLIENT_EXIT_DETACH: C2RustUnnamed_32 = 2;
pub const CLIENT_EXIT_SHUTDOWN: C2RustUnnamed_32 = 1;
pub const CLIENT_EXIT_RETURN: C2RustUnnamed_32 = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line {
    pub timer: event,
    pub screen: screen,
    pub active: *mut screen,
    pub references: libc::c_int,
    pub style: grid_cell,
    pub entries: [status_line_entry; 5],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line_entry {
    pub expanded: *mut libc::c_char,
    pub ranges: style_ranges,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_ranges {
    pub tqh_first: *mut style_range,
    pub tqh_last: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_range {
    pub type_0: style_range_type,
    pub argument: u_int,
    pub string: [libc::c_char; 16],
    pub start: u_int,
    pub end: u_int,
    pub entry: C2RustUnnamed_33,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_33 {
    pub tqe_next: *mut style_range,
    pub tqe_prev: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty {
    pub client: *mut client,
    pub start_timer: event,
    pub clipboard_timer: event,
    pub last_requests: time_t,
    pub sx: u_int,
    pub sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub ccolour: libc::c_int,
    pub oflag: libc::c_int,
    pub oox: u_int,
    pub ooy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub mode: libc::c_int,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub rlower: u_int,
    pub rupper: u_int,
    pub rleft: u_int,
    pub rright: u_int,
    pub event_in: event,
    pub in_0: *mut evbuffer,
    pub event_out: event,
    pub out: *mut evbuffer,
    pub timer: event,
    pub discarded: size_t,
    pub tio: termios,
    pub cell: grid_cell,
    pub last_cell: grid_cell,
    pub flags: libc::c_int,
    pub term: *mut tty_term,
    pub mouse_last_x: u_int,
    pub mouse_last_y: u_int,
    pub mouse_last_b: u_int,
    pub mouse_drag_flag: libc::c_int,
    pub mouse_scrolling_flag: libc::c_int,
    pub mouse_slider_mpos: libc::c_int,
    pub mouse_drag_update: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub mouse_drag_release: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub key_timer: event,
    pub key_tree: *mut tty_key,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty_term {
    pub name: *mut libc::c_char,
    pub tty: *mut tty,
    pub features: libc::c_int,
    pub acs: [[libc::c_char; 2]; 256],
    pub codes: *mut tty_code,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_34,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_34 {
    pub le_next: *mut tty_term,
    pub le_prev: *mut *mut tty_term,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_job_tree {
    pub rbh_root: *mut format_job,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_job {
    pub client: *mut client,
    pub tag: u_int,
    pub cmd: *const libc::c_char,
    pub expanded: *const libc::c_char,
    pub last: time_t,
    pub out: *mut libc::c_char,
    pub updated: libc::c_int,
    pub job: *mut job,
    pub status: libc::c_int,
    pub entry: C2RustUnnamed_35,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_35 {
    pub rbe_left: *mut format_job,
    pub rbe_right: *mut format_job,
    pub rbe_parent: *mut format_job,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_windows {
    pub rbh_root: *mut client_window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_window {
    pub window: u_int,
    pub pane: *mut window_pane,
    pub sx: u_int,
    pub sy: u_int,
    pub entry: C2RustUnnamed_36,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_36 {
    pub rbe_left: *mut client_window,
    pub rbe_right: *mut client_window,
    pub rbe_parent: *mut client_window,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct environ_entry {
    pub name: *mut libc::c_char,
    pub value: *mut libc::c_char,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_37,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_37 {
    pub rbe_left: *mut environ_entry,
    pub rbe_right: *mut environ_entry,
    pub rbe_parent: *mut environ_entry,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct session_group {
    pub name: *const libc::c_char,
    pub sessions: C2RustUnnamed_39,
    pub entry: C2RustUnnamed_38,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_38 {
    pub rbe_left: *mut session_group,
    pub rbe_right: *mut session_group,
    pub rbe_parent: *mut session_group,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_39 {
    pub tqh_first: *mut session,
    pub tqh_last: *mut *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sessions {
    pub rbh_root: *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct clients {
    pub tqh_first: *mut client,
    pub tqh_last: *mut *mut client,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_modifier {
    pub modifier: [libc::c_char; 3],
    pub size: u_int,
    pub argv: *mut *mut libc::c_char,
    pub argc: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_table_entry {
    pub key: *const libc::c_char,
    pub type_0: format_table_type,
    pub cb: format_cb,
}
pub type format_table_type = libc::c_uint;
pub const FORMAT_TABLE_TIME: format_table_type = 1;
pub const FORMAT_TABLE_STRING: format_table_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_expand_state {
    pub ft: *mut format_tree,
    pub loop_0: u_int,
    pub time: time_t,
    pub tm: tm,
    pub flags: libc::c_int,
}
pub const LESS_THAN_EQUAL: C2RustUnnamed_40 = 10;
pub const LESS_THAN: C2RustUnnamed_40 = 9;
pub const GREATER_THAN_EQUAL: C2RustUnnamed_40 = 8;
pub const GREATER_THAN: C2RustUnnamed_40 = 7;
pub const NOT_EQUAL: C2RustUnnamed_40 = 6;
pub const EQUAL: C2RustUnnamed_40 = 5;
pub const MODULUS: C2RustUnnamed_40 = 4;
pub const DIVIDE: C2RustUnnamed_40 = 3;
pub const MULTIPLY: C2RustUnnamed_40 = 2;
pub const SUBTRACT: C2RustUnnamed_40 = 1;
pub const ADD: C2RustUnnamed_40 = 0;
pub type C2RustUnnamed_40 = libc::c_uint;
pub type job_free_cb = Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
pub type job_complete_cb = Option<unsafe extern "C" fn(*mut job) -> ()>;
pub type job_update_cb = Option<unsafe extern "C" fn(*mut job) -> ()>;
static mut format_jobs: format_job_tree = {
    let mut init = format_job_tree {
        rbh_root: 0 as *const format_job as *mut format_job,
    };
    init
};
unsafe extern "C" fn format_job_tree_RB_INSERT(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) -> *mut format_job {
    let mut tmp: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut comp: libc::c_int = 0 as libc::c_int;
    tmp = (*head).rbh_root;
    while !tmp.is_null() {
        parent = tmp;
        comp = format_job_cmp(elm, parent);
        if comp < 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_left;
        } else if comp > 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_right;
        } else {
            return tmp;
        }
    }
    (*elm).entry.rbe_parent = parent;
    (*elm).entry.rbe_right = std::ptr::null_mut::<format_job>();
    (*elm).entry.rbe_left = (*elm).entry.rbe_right;
    (*elm).entry.rbe_color = 1 as libc::c_int;
    if !parent.is_null() {
        if comp < 0 as libc::c_int {
            (*parent).entry.rbe_left = elm;
        } else {
            (*parent).entry.rbe_right = elm;
        }
    } else {
        (*head).rbh_root = elm;
    }
    format_job_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<format_job>();
}
unsafe extern "C" fn format_job_tree_RB_REMOVE(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) -> *mut format_job {
    let mut current_block: u64;
    let mut child: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut old: *mut format_job = elm;
    let mut color: libc::c_int = 0;
    if ((*elm).entry.rbe_left).is_null() {
        child = (*elm).entry.rbe_right;
        current_block = 7245201122033322888;
    } else if ((*elm).entry.rbe_right).is_null() {
        child = (*elm).entry.rbe_left;
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut format_job = std::ptr::null_mut::<format_job>();
        elm = (*elm).entry.rbe_right;
        loop {
            left = (*elm).entry.rbe_left;
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = (*elm).entry.rbe_right;
        parent = (*elm).entry.rbe_parent;
        color = (*elm).entry.rbe_color;
        if !child.is_null() {
            (*child).entry.rbe_parent = parent;
        }
        if !parent.is_null() {
            if (*parent).entry.rbe_left == elm {
                (*parent).entry.rbe_left = child;
            } else {
                (*parent).entry.rbe_right = child;
            }
        } else {
            (*head).rbh_root = child;
        }
        if (*elm).entry.rbe_parent == old {
            parent = elm;
        }
        (*elm).entry = (*old).entry;
        if !((*old).entry.rbe_parent).is_null() {
            if (*(*old).entry.rbe_parent).entry.rbe_left == old {
                (*(*old).entry.rbe_parent).entry.rbe_left = elm;
            } else {
                (*(*old).entry.rbe_parent).entry.rbe_right = elm;
            }
        } else {
            (*head).rbh_root = elm;
        }
        (*(*old).entry.rbe_left).entry.rbe_parent = elm;
        if !((*old).entry.rbe_right).is_null() {
            (*(*old).entry.rbe_right).entry.rbe_parent = elm;
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = (*left).entry.rbe_parent;
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 13966504069422014721;
    }
    match current_block {
        7245201122033322888 => {
            parent = (*elm).entry.rbe_parent;
            color = (*elm).entry.rbe_color;
            if !child.is_null() {
                (*child).entry.rbe_parent = parent;
            }
            if !parent.is_null() {
                if (*parent).entry.rbe_left == elm {
                    (*parent).entry.rbe_left = child;
                } else {
                    (*parent).entry.rbe_right = child;
                }
            } else {
                (*head).rbh_root = child;
            }
        }
        _ => {}
    }
    if color == 0 as libc::c_int {
        format_job_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
unsafe extern "C" fn format_job_tree_RB_INSERT_COLOR(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) {
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut gparent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut tmp: *mut format_job = std::ptr::null_mut::<format_job>();
    loop {
        parent = (*elm).entry.rbe_parent;
        if parent.is_null() || (*parent).entry.rbe_color != 1 as libc::c_int {
            break;
        }
        gparent = (*parent).entry.rbe_parent;
        if parent == (*gparent).entry.rbe_left {
            tmp = (*gparent).entry.rbe_right;
            if !tmp.is_null() && (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                elm = gparent;
            } else {
                if (*parent).entry.rbe_right == elm {
                    tmp = (*parent).entry.rbe_right;
                    (*parent).entry.rbe_right = (*tmp).entry.rbe_left;
                    if !((*parent).entry.rbe_right).is_null() {
                        (*(*tmp).entry.rbe_left).entry.rbe_parent = parent;
                    }
                    (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                    if !((*tmp).entry.rbe_parent).is_null() {
                        if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                            (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                        } else {
                            (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).entry.rbe_left = parent;
                    (*parent).entry.rbe_parent = tmp;
                    !((*tmp).entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*gparent).entry.rbe_left;
                (*gparent).entry.rbe_left = (*tmp).entry.rbe_right;
                if !((*gparent).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_parent = gparent;
                }
                (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if gparent == (*(*gparent).entry.rbe_parent).entry.rbe_left {
                        (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_right = gparent;
                (*gparent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
            }
        } else {
            tmp = (*gparent).entry.rbe_left;
            if !tmp.is_null() && (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                elm = gparent;
            } else {
                if (*parent).entry.rbe_left == elm {
                    tmp = (*parent).entry.rbe_left;
                    (*parent).entry.rbe_left = (*tmp).entry.rbe_right;
                    if !((*parent).entry.rbe_left).is_null() {
                        (*(*tmp).entry.rbe_right).entry.rbe_parent = parent;
                    }
                    (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                    if !((*tmp).entry.rbe_parent).is_null() {
                        if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                            (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                        } else {
                            (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).entry.rbe_right = parent;
                    (*parent).entry.rbe_parent = tmp;
                    !((*tmp).entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*gparent).entry.rbe_right;
                (*gparent).entry.rbe_right = (*tmp).entry.rbe_left;
                if !((*gparent).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_parent = gparent;
                }
                (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if gparent == (*(*gparent).entry.rbe_parent).entry.rbe_left {
                        (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_left = gparent;
                (*gparent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
            }
        }
    }
    (*(*head).rbh_root).entry.rbe_color = 0 as libc::c_int;
}
unsafe extern "C" fn format_job_tree_RB_FIND(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) -> *mut format_job {
    let mut tmp: *mut format_job = (*head).rbh_root;
    let mut comp: libc::c_int = 0;
    while !tmp.is_null() {
        comp = format_job_cmp(elm, tmp);
        if comp < 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_left;
        } else if comp > 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_right;
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<format_job>();
}
unsafe extern "C" fn format_job_tree_RB_REMOVE_COLOR(
    mut head: *mut format_job_tree,
    mut parent: *mut format_job,
    mut elm: *mut format_job,
) {
    let mut tmp: *mut format_job = std::ptr::null_mut::<format_job>();
    while (elm.is_null() || (*elm).entry.rbe_color == 0 as libc::c_int) && elm != (*head).rbh_root {
        if (*parent).entry.rbe_left == elm {
            tmp = (*parent).entry.rbe_right;
            if (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*parent).entry.rbe_right;
                (*parent).entry.rbe_right = (*tmp).entry.rbe_left;
                if !((*parent).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_left = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                tmp = (*parent).entry.rbe_right;
            }
            if (((*tmp).entry.rbe_left).is_null()
                || (*(*tmp).entry.rbe_left).entry.rbe_color == 0 as libc::c_int)
                && (((*tmp).entry.rbe_right).is_null()
                    || (*(*tmp).entry.rbe_right).entry.rbe_color == 0 as libc::c_int)
            {
                (*tmp).entry.rbe_color = 1 as libc::c_int;
                elm = parent;
                parent = (*elm).entry.rbe_parent;
            } else {
                if ((*tmp).entry.rbe_right).is_null()
                    || (*(*tmp).entry.rbe_right).entry.rbe_color == 0 as libc::c_int
                {
                    let mut oleft: *mut format_job = std::ptr::null_mut::<format_job>();
                    oleft = (*tmp).entry.rbe_left;
                    if !oleft.is_null() {
                        (*oleft).entry.rbe_color = 0 as libc::c_int;
                    }
                    (*tmp).entry.rbe_color = 1 as libc::c_int;
                    oleft = (*tmp).entry.rbe_left;
                    (*tmp).entry.rbe_left = (*oleft).entry.rbe_right;
                    if !((*tmp).entry.rbe_left).is_null() {
                        (*(*oleft).entry.rbe_right).entry.rbe_parent = tmp;
                    }
                    (*oleft).entry.rbe_parent = (*tmp).entry.rbe_parent;
                    if !((*oleft).entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).entry.rbe_parent).entry.rbe_left {
                            (*(*tmp).entry.rbe_parent).entry.rbe_left = oleft;
                        } else {
                            (*(*tmp).entry.rbe_parent).entry.rbe_right = oleft;
                        }
                    } else {
                        (*head).rbh_root = oleft;
                    }
                    (*oleft).entry.rbe_right = tmp;
                    (*tmp).entry.rbe_parent = oleft;
                    !((*oleft).entry.rbe_parent).is_null();
                    tmp = (*parent).entry.rbe_right;
                }
                (*tmp).entry.rbe_color = (*parent).entry.rbe_color;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                if !((*tmp).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_color = 0 as libc::c_int;
                }
                tmp = (*parent).entry.rbe_right;
                (*parent).entry.rbe_right = (*tmp).entry.rbe_left;
                if !((*parent).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_left = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        } else {
            tmp = (*parent).entry.rbe_left;
            if (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*parent).entry.rbe_left;
                (*parent).entry.rbe_left = (*tmp).entry.rbe_right;
                if !((*parent).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_right = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                tmp = (*parent).entry.rbe_left;
            }
            if (((*tmp).entry.rbe_left).is_null()
                || (*(*tmp).entry.rbe_left).entry.rbe_color == 0 as libc::c_int)
                && (((*tmp).entry.rbe_right).is_null()
                    || (*(*tmp).entry.rbe_right).entry.rbe_color == 0 as libc::c_int)
            {
                (*tmp).entry.rbe_color = 1 as libc::c_int;
                elm = parent;
                parent = (*elm).entry.rbe_parent;
            } else {
                if ((*tmp).entry.rbe_left).is_null()
                    || (*(*tmp).entry.rbe_left).entry.rbe_color == 0 as libc::c_int
                {
                    let mut oright: *mut format_job = std::ptr::null_mut::<format_job>();
                    oright = (*tmp).entry.rbe_right;
                    if !oright.is_null() {
                        (*oright).entry.rbe_color = 0 as libc::c_int;
                    }
                    (*tmp).entry.rbe_color = 1 as libc::c_int;
                    oright = (*tmp).entry.rbe_right;
                    (*tmp).entry.rbe_right = (*oright).entry.rbe_left;
                    if !((*tmp).entry.rbe_right).is_null() {
                        (*(*oright).entry.rbe_left).entry.rbe_parent = tmp;
                    }
                    (*oright).entry.rbe_parent = (*tmp).entry.rbe_parent;
                    if !((*oright).entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).entry.rbe_parent).entry.rbe_left {
                            (*(*tmp).entry.rbe_parent).entry.rbe_left = oright;
                        } else {
                            (*(*tmp).entry.rbe_parent).entry.rbe_right = oright;
                        }
                    } else {
                        (*head).rbh_root = oright;
                    }
                    (*oright).entry.rbe_left = tmp;
                    (*tmp).entry.rbe_parent = oright;
                    !((*oright).entry.rbe_parent).is_null();
                    tmp = (*parent).entry.rbe_left;
                }
                (*tmp).entry.rbe_color = (*parent).entry.rbe_color;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                if !((*tmp).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_color = 0 as libc::c_int;
                }
                tmp = (*parent).entry.rbe_left;
                (*parent).entry.rbe_left = (*tmp).entry.rbe_right;
                if !((*parent).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_right = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        }
    }
    if !elm.is_null() {
        (*elm).entry.rbe_color = 0 as libc::c_int;
    }
}
unsafe extern "C" fn format_job_tree_RB_NEXT(mut elm: *mut format_job) -> *mut format_job {
    if !((*elm).entry.rbe_right).is_null() {
        elm = (*elm).entry.rbe_right;
        while !((*elm).entry.rbe_left).is_null() {
            elm = (*elm).entry.rbe_left;
        }
    } else if !((*elm).entry.rbe_parent).is_null()
        && elm == (*(*elm).entry.rbe_parent).entry.rbe_left
    {
        elm = (*elm).entry.rbe_parent;
    } else {
        while !((*elm).entry.rbe_parent).is_null()
            && elm == (*(*elm).entry.rbe_parent).entry.rbe_right
        {
            elm = (*elm).entry.rbe_parent;
        }
        elm = (*elm).entry.rbe_parent;
    }
    return elm;
}
unsafe extern "C" fn format_job_tree_RB_MINMAX(
    mut head: *mut format_job_tree,
    mut val: libc::c_int,
) -> *mut format_job {
    let mut tmp: *mut format_job = (*head).rbh_root;
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    while !tmp.is_null() {
        parent = tmp;
        if val < 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_left;
        } else {
            tmp = (*tmp).entry.rbe_right;
        }
    }
    return parent;
}
unsafe extern "C" fn format_job_cmp(
    mut fj1: *mut format_job,
    mut fj2: *mut format_job,
) -> libc::c_int {
    if (*fj1).tag < (*fj2).tag {
        return -(1 as libc::c_int);
    }
    if (*fj1).tag > (*fj2).tag {
        return 1 as libc::c_int;
    }
    return strcmp((*fj1).cmd, (*fj2).cmd);
}
unsafe extern "C" fn format_entry_tree_RB_REMOVE(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) -> *mut format_entry {
    let mut current_block: u64;
    let mut child: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut old: *mut format_entry = elm;
    let mut color: libc::c_int = 0;
    if ((*elm).entry.rbe_left).is_null() {
        child = (*elm).entry.rbe_right;
        current_block = 7245201122033322888;
    } else if ((*elm).entry.rbe_right).is_null() {
        child = (*elm).entry.rbe_left;
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut format_entry = std::ptr::null_mut::<format_entry>();
        elm = (*elm).entry.rbe_right;
        loop {
            left = (*elm).entry.rbe_left;
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = (*elm).entry.rbe_right;
        parent = (*elm).entry.rbe_parent;
        color = (*elm).entry.rbe_color;
        if !child.is_null() {
            (*child).entry.rbe_parent = parent;
        }
        if !parent.is_null() {
            if (*parent).entry.rbe_left == elm {
                (*parent).entry.rbe_left = child;
            } else {
                (*parent).entry.rbe_right = child;
            }
        } else {
            (*head).rbh_root = child;
        }
        if (*elm).entry.rbe_parent == old {
            parent = elm;
        }
        (*elm).entry = (*old).entry;
        if !((*old).entry.rbe_parent).is_null() {
            if (*(*old).entry.rbe_parent).entry.rbe_left == old {
                (*(*old).entry.rbe_parent).entry.rbe_left = elm;
            } else {
                (*(*old).entry.rbe_parent).entry.rbe_right = elm;
            }
        } else {
            (*head).rbh_root = elm;
        }
        (*(*old).entry.rbe_left).entry.rbe_parent = elm;
        if !((*old).entry.rbe_right).is_null() {
            (*(*old).entry.rbe_right).entry.rbe_parent = elm;
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = (*left).entry.rbe_parent;
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 17454932169446422658;
    }
    match current_block {
        7245201122033322888 => {
            parent = (*elm).entry.rbe_parent;
            color = (*elm).entry.rbe_color;
            if !child.is_null() {
                (*child).entry.rbe_parent = parent;
            }
            if !parent.is_null() {
                if (*parent).entry.rbe_left == elm {
                    (*parent).entry.rbe_left = child;
                } else {
                    (*parent).entry.rbe_right = child;
                }
            } else {
                (*head).rbh_root = child;
            }
        }
        _ => {}
    }
    if color == 0 as libc::c_int {
        format_entry_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
unsafe extern "C" fn format_entry_tree_RB_FIND(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) -> *mut format_entry {
    let mut tmp: *mut format_entry = (*head).rbh_root;
    let mut comp: libc::c_int = 0;
    while !tmp.is_null() {
        comp = format_entry_cmp(elm, tmp);
        if comp < 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_left;
        } else if comp > 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_right;
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<format_entry>();
}
unsafe extern "C" fn format_entry_tree_RB_MINMAX(
    mut head: *mut format_entry_tree,
    mut val: libc::c_int,
) -> *mut format_entry {
    let mut tmp: *mut format_entry = (*head).rbh_root;
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    while !tmp.is_null() {
        parent = tmp;
        if val < 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_left;
        } else {
            tmp = (*tmp).entry.rbe_right;
        }
    }
    return parent;
}
unsafe extern "C" fn format_entry_tree_RB_INSERT_COLOR(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) {
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut gparent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut tmp: *mut format_entry = std::ptr::null_mut::<format_entry>();
    loop {
        parent = (*elm).entry.rbe_parent;
        if parent.is_null() || (*parent).entry.rbe_color != 1 as libc::c_int {
            break;
        }
        gparent = (*parent).entry.rbe_parent;
        if parent == (*gparent).entry.rbe_left {
            tmp = (*gparent).entry.rbe_right;
            if !tmp.is_null() && (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                elm = gparent;
            } else {
                if (*parent).entry.rbe_right == elm {
                    tmp = (*parent).entry.rbe_right;
                    (*parent).entry.rbe_right = (*tmp).entry.rbe_left;
                    if !((*parent).entry.rbe_right).is_null() {
                        (*(*tmp).entry.rbe_left).entry.rbe_parent = parent;
                    }
                    (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                    if !((*tmp).entry.rbe_parent).is_null() {
                        if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                            (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                        } else {
                            (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).entry.rbe_left = parent;
                    (*parent).entry.rbe_parent = tmp;
                    !((*tmp).entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*gparent).entry.rbe_left;
                (*gparent).entry.rbe_left = (*tmp).entry.rbe_right;
                if !((*gparent).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_parent = gparent;
                }
                (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if gparent == (*(*gparent).entry.rbe_parent).entry.rbe_left {
                        (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_right = gparent;
                (*gparent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
            }
        } else {
            tmp = (*gparent).entry.rbe_left;
            if !tmp.is_null() && (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                elm = gparent;
            } else {
                if (*parent).entry.rbe_left == elm {
                    tmp = (*parent).entry.rbe_left;
                    (*parent).entry.rbe_left = (*tmp).entry.rbe_right;
                    if !((*parent).entry.rbe_left).is_null() {
                        (*(*tmp).entry.rbe_right).entry.rbe_parent = parent;
                    }
                    (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                    if !((*tmp).entry.rbe_parent).is_null() {
                        if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                            (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                        } else {
                            (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).entry.rbe_right = parent;
                    (*parent).entry.rbe_parent = tmp;
                    !((*tmp).entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).entry.rbe_color = 0 as libc::c_int;
                (*gparent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*gparent).entry.rbe_right;
                (*gparent).entry.rbe_right = (*tmp).entry.rbe_left;
                if !((*gparent).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_parent = gparent;
                }
                (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if gparent == (*(*gparent).entry.rbe_parent).entry.rbe_left {
                        (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_left = gparent;
                (*gparent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
            }
        }
    }
    (*(*head).rbh_root).entry.rbe_color = 0 as libc::c_int;
}
unsafe extern "C" fn format_entry_tree_RB_INSERT(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) -> *mut format_entry {
    let mut tmp: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut comp: libc::c_int = 0 as libc::c_int;
    tmp = (*head).rbh_root;
    while !tmp.is_null() {
        parent = tmp;
        comp = format_entry_cmp(elm, parent);
        if comp < 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_left;
        } else if comp > 0 as libc::c_int {
            tmp = (*tmp).entry.rbe_right;
        } else {
            return tmp;
        }
    }
    (*elm).entry.rbe_parent = parent;
    (*elm).entry.rbe_right = std::ptr::null_mut::<format_entry>();
    (*elm).entry.rbe_left = (*elm).entry.rbe_right;
    (*elm).entry.rbe_color = 1 as libc::c_int;
    if !parent.is_null() {
        if comp < 0 as libc::c_int {
            (*parent).entry.rbe_left = elm;
        } else {
            (*parent).entry.rbe_right = elm;
        }
    } else {
        (*head).rbh_root = elm;
    }
    format_entry_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<format_entry>();
}
unsafe extern "C" fn format_entry_tree_RB_REMOVE_COLOR(
    mut head: *mut format_entry_tree,
    mut parent: *mut format_entry,
    mut elm: *mut format_entry,
) {
    let mut tmp: *mut format_entry = std::ptr::null_mut::<format_entry>();
    while (elm.is_null() || (*elm).entry.rbe_color == 0 as libc::c_int) && elm != (*head).rbh_root {
        if (*parent).entry.rbe_left == elm {
            tmp = (*parent).entry.rbe_right;
            if (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*parent).entry.rbe_right;
                (*parent).entry.rbe_right = (*tmp).entry.rbe_left;
                if !((*parent).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_left = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                tmp = (*parent).entry.rbe_right;
            }
            if (((*tmp).entry.rbe_left).is_null()
                || (*(*tmp).entry.rbe_left).entry.rbe_color == 0 as libc::c_int)
                && (((*tmp).entry.rbe_right).is_null()
                    || (*(*tmp).entry.rbe_right).entry.rbe_color == 0 as libc::c_int)
            {
                (*tmp).entry.rbe_color = 1 as libc::c_int;
                elm = parent;
                parent = (*elm).entry.rbe_parent;
            } else {
                if ((*tmp).entry.rbe_right).is_null()
                    || (*(*tmp).entry.rbe_right).entry.rbe_color == 0 as libc::c_int
                {
                    let mut oleft: *mut format_entry = std::ptr::null_mut::<format_entry>();
                    oleft = (*tmp).entry.rbe_left;
                    if !oleft.is_null() {
                        (*oleft).entry.rbe_color = 0 as libc::c_int;
                    }
                    (*tmp).entry.rbe_color = 1 as libc::c_int;
                    oleft = (*tmp).entry.rbe_left;
                    (*tmp).entry.rbe_left = (*oleft).entry.rbe_right;
                    if !((*tmp).entry.rbe_left).is_null() {
                        (*(*oleft).entry.rbe_right).entry.rbe_parent = tmp;
                    }
                    (*oleft).entry.rbe_parent = (*tmp).entry.rbe_parent;
                    if !((*oleft).entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).entry.rbe_parent).entry.rbe_left {
                            (*(*tmp).entry.rbe_parent).entry.rbe_left = oleft;
                        } else {
                            (*(*tmp).entry.rbe_parent).entry.rbe_right = oleft;
                        }
                    } else {
                        (*head).rbh_root = oleft;
                    }
                    (*oleft).entry.rbe_right = tmp;
                    (*tmp).entry.rbe_parent = oleft;
                    !((*oleft).entry.rbe_parent).is_null();
                    tmp = (*parent).entry.rbe_right;
                }
                (*tmp).entry.rbe_color = (*parent).entry.rbe_color;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                if !((*tmp).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_color = 0 as libc::c_int;
                }
                tmp = (*parent).entry.rbe_right;
                (*parent).entry.rbe_right = (*tmp).entry.rbe_left;
                if !((*parent).entry.rbe_right).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_left = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        } else {
            tmp = (*parent).entry.rbe_left;
            if (*tmp).entry.rbe_color == 1 as libc::c_int {
                (*tmp).entry.rbe_color = 0 as libc::c_int;
                (*parent).entry.rbe_color = 1 as libc::c_int;
                tmp = (*parent).entry.rbe_left;
                (*parent).entry.rbe_left = (*tmp).entry.rbe_right;
                if !((*parent).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_right = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                tmp = (*parent).entry.rbe_left;
            }
            if (((*tmp).entry.rbe_left).is_null()
                || (*(*tmp).entry.rbe_left).entry.rbe_color == 0 as libc::c_int)
                && (((*tmp).entry.rbe_right).is_null()
                    || (*(*tmp).entry.rbe_right).entry.rbe_color == 0 as libc::c_int)
            {
                (*tmp).entry.rbe_color = 1 as libc::c_int;
                elm = parent;
                parent = (*elm).entry.rbe_parent;
            } else {
                if ((*tmp).entry.rbe_left).is_null()
                    || (*(*tmp).entry.rbe_left).entry.rbe_color == 0 as libc::c_int
                {
                    let mut oright: *mut format_entry = std::ptr::null_mut::<format_entry>();
                    oright = (*tmp).entry.rbe_right;
                    if !oright.is_null() {
                        (*oright).entry.rbe_color = 0 as libc::c_int;
                    }
                    (*tmp).entry.rbe_color = 1 as libc::c_int;
                    oright = (*tmp).entry.rbe_right;
                    (*tmp).entry.rbe_right = (*oright).entry.rbe_left;
                    if !((*tmp).entry.rbe_right).is_null() {
                        (*(*oright).entry.rbe_left).entry.rbe_parent = tmp;
                    }
                    (*oright).entry.rbe_parent = (*tmp).entry.rbe_parent;
                    if !((*oright).entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).entry.rbe_parent).entry.rbe_left {
                            (*(*tmp).entry.rbe_parent).entry.rbe_left = oright;
                        } else {
                            (*(*tmp).entry.rbe_parent).entry.rbe_right = oright;
                        }
                    } else {
                        (*head).rbh_root = oright;
                    }
                    (*oright).entry.rbe_left = tmp;
                    (*tmp).entry.rbe_parent = oright;
                    !((*oright).entry.rbe_parent).is_null();
                    tmp = (*parent).entry.rbe_left;
                }
                (*tmp).entry.rbe_color = (*parent).entry.rbe_color;
                (*parent).entry.rbe_color = 0 as libc::c_int;
                if !((*tmp).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_left).entry.rbe_color = 0 as libc::c_int;
                }
                tmp = (*parent).entry.rbe_left;
                (*parent).entry.rbe_left = (*tmp).entry.rbe_right;
                if !((*parent).entry.rbe_left).is_null() {
                    (*(*tmp).entry.rbe_right).entry.rbe_parent = parent;
                }
                (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent;
                if !((*tmp).entry.rbe_parent).is_null() {
                    if parent == (*(*parent).entry.rbe_parent).entry.rbe_left {
                        (*(*parent).entry.rbe_parent).entry.rbe_left = tmp;
                    } else {
                        (*(*parent).entry.rbe_parent).entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).entry.rbe_right = parent;
                (*parent).entry.rbe_parent = tmp;
                !((*tmp).entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        }
    }
    if !elm.is_null() {
        (*elm).entry.rbe_color = 0 as libc::c_int;
    }
}
unsafe extern "C" fn format_entry_tree_RB_NEXT(mut elm: *mut format_entry) -> *mut format_entry {
    if !((*elm).entry.rbe_right).is_null() {
        elm = (*elm).entry.rbe_right;
        while !((*elm).entry.rbe_left).is_null() {
            elm = (*elm).entry.rbe_left;
        }
    } else if !((*elm).entry.rbe_parent).is_null()
        && elm == (*(*elm).entry.rbe_parent).entry.rbe_left
    {
        elm = (*elm).entry.rbe_parent;
    } else {
        while !((*elm).entry.rbe_parent).is_null()
            && elm == (*(*elm).entry.rbe_parent).entry.rbe_right
        {
            elm = (*elm).entry.rbe_parent;
        }
        elm = (*elm).entry.rbe_parent;
    }
    return elm;
}
unsafe extern "C" fn format_entry_cmp(
    mut fe1: *mut format_entry,
    mut fe2: *mut format_entry,
) -> libc::c_int {
    return strcmp((*fe1).key, (*fe2).key);
}
static mut format_upper: [*const libc::c_char; 26] = [
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    b"pane_id\0" as *const u8 as *const libc::c_char,
    0 as *const libc::c_char,
    b"window_flags\0" as *const u8 as *const libc::c_char,
    0 as *const libc::c_char,
    b"host\0" as *const u8 as *const libc::c_char,
    b"window_index\0" as *const u8 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    b"pane_index\0" as *const u8 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    b"session_name\0" as *const u8 as *const libc::c_char,
    b"pane_title\0" as *const u8 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    b"window_name\0" as *const u8 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
];
static mut format_lower: [*const libc::c_char; 26] = [
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    b"host_short\0" as *const u8 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
    0 as *const libc::c_char,
];
#[inline]
unsafe extern "C" fn format_logging(mut ft: *mut format_tree) -> libc::c_int {
    return (log_get_level() != 0 as libc::c_int || (*ft).flags & 0x8 as libc::c_int != 0)
        as libc::c_int;
}
unsafe extern "C" fn format_log1(
    mut es: *mut format_expand_state,
    mut from: *const libc::c_char,
    mut fmt: *const libc::c_char,
    mut args: ...
) {
    let mut ft: *mut format_tree = (*es).ft;
    let mut ap: ::core::ffi::VaListImpl;
    let mut s: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    static mut spaces: [libc::c_char; 11] =
        unsafe { *::core::mem::transmute::<&[u8; 11], &[libc::c_char; 11]>(b"          \0") };
    if format_logging(ft) == 0 {
        return;
    }
    ap = args.clone();
    xvasprintf(&mut s, fmt, ap.as_va_list());
    log_debug(b"%s: %s\0" as *const u8 as *const libc::c_char, from, s);
    if !((*ft).item).is_null() && (*ft).flags & 0x8 as libc::c_int != 0 {
        cmdq_print(
            (*ft).item,
            b"#%.*s%s\0" as *const u8 as *const libc::c_char,
            (*es).loop_0,
            spaces.as_ptr(),
            s,
        );
    }
    free(s as *mut libc::c_void);
}
unsafe extern "C" fn format_copy_state(
    mut to: *mut format_expand_state,
    mut from: *mut format_expand_state,
    mut flags: libc::c_int,
) {
    (*to).ft = (*from).ft;
    (*to).loop_0 = (*from).loop_0;
    (*to).time = (*from).time;
    memcpy(
        &mut (*to).tm as *mut tm as *mut libc::c_void,
        &mut (*from).tm as *mut tm as *const libc::c_void,
        ::core::mem::size_of::<tm>() as libc::c_ulong,
    );
    (*to).flags = (*from).flags | flags;
}
unsafe extern "C" fn format_job_update(mut job: *mut job) {
    let mut fj: *mut format_job = job_get_data(job) as *mut format_job;
    let mut evb: *mut evbuffer = (*job_get_event(job)).input;
    let mut line: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut next: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut t: time_t = 0;
    loop {
        next = evbuffer_readline(evb);
        if next.is_null() {
            break;
        }
        free(line as *mut libc::c_void);
        line = next;
    }
    if line.is_null() {
        return;
    }
    (*fj).updated = 1 as libc::c_int;
    free((*fj).out as *mut libc::c_void);
    (*fj).out = line;
    log_debug(
        b"%s: %p %s: %s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"format_job_update\0"))
            .as_ptr(),
        fj,
        (*fj).cmd,
        (*fj).out,
    );
    t = time(std::ptr::null_mut::<time_t>());
    if (*fj).status != 0 && (*fj).last != t {
        if !((*fj).client).is_null() {
            server_status_client((*fj).client);
        }
        (*fj).last = t;
    }
}
unsafe extern "C" fn format_job_complete(mut job: *mut job) {
    let mut fj: *mut format_job = job_get_data(job) as *mut format_job;
    let mut evb: *mut evbuffer = (*job_get_event(job)).input;
    let mut line: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut buf: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut len: size_t = 0;
    (*fj).job = std::ptr::null_mut::<job>();
    buf = std::ptr::null_mut::<libc::c_char>();
    line = evbuffer_readline(evb);
    if line.is_null() {
        len = evbuffer_get_length(evb);
        buf = xmalloc(len.wrapping_add(1 as libc::c_int as libc::c_ulong)) as *mut libc::c_char;
        if len != 0 as libc::c_int as libc::c_ulong {
            memcpy(
                buf as *mut libc::c_void,
                evbuffer_pullup(evb, -(1 as libc::c_int) as ssize_t) as *const libc::c_void,
                len,
            );
        }
        *buf.offset(len as isize) = '\0' as i32 as libc::c_char;
    } else {
        buf = line;
    }
    log_debug(
        b"%s: %p %s: %s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 20], &[libc::c_char; 20]>(b"format_job_complete\0"))
            .as_ptr(),
        fj,
        (*fj).cmd,
        buf,
    );
    if *buf as libc::c_int != '\0' as i32 || (*fj).updated == 0 {
        free((*fj).out as *mut libc::c_void);
        (*fj).out = buf;
    } else {
        free(buf as *mut libc::c_void);
    }
    if (*fj).status != 0 {
        if !((*fj).client).is_null() {
            server_status_client((*fj).client);
        }
        (*fj).status = 0 as libc::c_int;
    }
}
unsafe extern "C" fn format_job_get(
    mut es: *mut format_expand_state,
    mut cmd: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = (*es).ft;
    let mut jobs: *mut format_job_tree = std::ptr::null_mut::<format_job_tree>();
    let mut fj0: format_job = format_job {
        client: std::ptr::null_mut::<client>(),
        tag: 0,
        cmd: std::ptr::null::<libc::c_char>(),
        expanded: std::ptr::null::<libc::c_char>(),
        last: 0,
        out: std::ptr::null_mut::<libc::c_char>(),
        updated: 0,
        job: std::ptr::null_mut::<job>(),
        status: 0,
        entry: C2RustUnnamed_35 {
            rbe_left: std::ptr::null_mut::<format_job>(),
            rbe_right: std::ptr::null_mut::<format_job>(),
            rbe_parent: std::ptr::null_mut::<format_job>(),
            rbe_color: 0,
        },
    };
    let mut fj: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut t: time_t = 0;
    let mut expanded: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut force: libc::c_int = 0;
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    if ((*ft).client).is_null() {
        jobs = &mut format_jobs;
    } else if !((*(*ft).client).jobs).is_null() {
        jobs = (*(*ft).client).jobs;
    } else {
        (*(*ft).client).jobs = xmalloc(::core::mem::size_of::<format_job_tree>() as libc::c_ulong)
            as *mut format_job_tree;
        jobs = (*(*ft).client).jobs;
        (*jobs).rbh_root = std::ptr::null_mut::<format_job>();
    }
    fj0.tag = (*ft).tag;
    fj0.cmd = cmd;
    fj = format_job_tree_RB_FIND(jobs, &mut fj0);
    if fj.is_null() {
        fj = xcalloc(
            1 as libc::c_int as size_t,
            ::core::mem::size_of::<format_job>() as libc::c_ulong,
        ) as *mut format_job;
        (*fj).client = (*ft).client;
        (*fj).tag = (*ft).tag;
        (*fj).cmd = xstrdup(cmd);
        format_job_tree_RB_INSERT(jobs, fj);
    }
    format_copy_state(&mut next, es, 0x2 as libc::c_int);
    next.flags &= !(0x1 as libc::c_int);
    expanded = format_expand1(&mut next, cmd);
    if ((*fj).expanded).is_null() || strcmp(expanded, (*fj).expanded) != 0 as libc::c_int {
        free((*fj).expanded as *mut libc::c_void);
        (*fj).expanded = xstrdup(expanded);
        force = 1 as libc::c_int;
    } else {
        force = (*ft).flags & 0x2 as libc::c_int;
    }
    t = time(std::ptr::null_mut::<time_t>());
    if force != 0 && !((*fj).job).is_null() {
        job_free((*fj).job);
    }
    if force != 0 || ((*fj).job).is_null() && (*fj).last != t {
        (*fj).job = job_run(
            expanded,
            0 as libc::c_int,
            std::ptr::null_mut::<*mut libc::c_char>(),
            std::ptr::null_mut::<environ>(),
            std::ptr::null_mut::<session>(),
            server_client_get_cwd((*ft).client, std::ptr::null_mut::<session>()),
            Some(format_job_update as unsafe extern "C" fn(*mut job) -> ()),
            Some(format_job_complete as unsafe extern "C" fn(*mut job) -> ()),
            None,
            fj as *mut libc::c_void,
            0x1 as libc::c_int,
            -(1 as libc::c_int),
            -(1 as libc::c_int),
        );
        if ((*fj).job).is_null() {
            free((*fj).out as *mut libc::c_void);
            xasprintf(
                &mut (*fj).out as *mut *mut libc::c_char,
                b"<'%s' didn't start>\0" as *const u8 as *const libc::c_char,
                (*fj).cmd,
            );
        }
        (*fj).last = t;
        (*fj).updated = 0 as libc::c_int;
    } else if !((*fj).job).is_null()
        && t - (*fj).last > 1 as libc::c_int as libc::c_long
        && ((*fj).out).is_null()
    {
        xasprintf(
            &mut (*fj).out as *mut *mut libc::c_char,
            b"<'%s' not ready>\0" as *const u8 as *const libc::c_char,
            (*fj).cmd,
        );
    }
    free(expanded as *mut libc::c_void);
    if (*ft).flags & 0x1 as libc::c_int != 0 {
        (*fj).status = 1 as libc::c_int;
    }
    if ((*fj).out).is_null() {
        return xstrdup(b"\0" as *const u8 as *const libc::c_char);
    }
    return format_expand1(&mut next, (*fj).out);
}
unsafe extern "C" fn format_job_tidy(mut jobs: *mut format_job_tree, mut force: libc::c_int) {
    let mut fj: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut fj1: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut now: time_t = 0;
    now = time(std::ptr::null_mut::<time_t>());
    fj = format_job_tree_RB_MINMAX(jobs, -(1 as libc::c_int));
    while !fj.is_null() && {
        fj1 = format_job_tree_RB_NEXT(fj);
        1 as libc::c_int != 0
    } {
        if !(force == 0
            && ((*fj).last > now || now - (*fj).last < 3600 as libc::c_int as libc::c_long))
        {
            format_job_tree_RB_REMOVE(jobs, fj);
            log_debug(
                b"%s: %s\0" as *const u8 as *const libc::c_char,
                (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_job_tidy\0"))
                    .as_ptr(),
                (*fj).cmd,
            );
            if !((*fj).job).is_null() {
                job_free((*fj).job);
            }
            free((*fj).expanded as *mut libc::c_void);
            free((*fj).cmd as *mut libc::c_void);
            free((*fj).out as *mut libc::c_void);
            free(fj as *mut libc::c_void);
        }
        fj = fj1;
    }
}
#[no_mangle]
pub unsafe extern "C" fn format_tidy_jobs() {
    let mut c: *mut client = std::ptr::null_mut::<client>();
    format_job_tidy(&mut format_jobs, 0 as libc::c_int);
    c = clients.tqh_first;
    while !c.is_null() {
        if !((*c).jobs).is_null() {
            format_job_tidy((*c).jobs, 0 as libc::c_int);
        }
        c = (*c).entry.tqe_next;
    }
}
#[no_mangle]
pub unsafe extern "C" fn format_lost_client(mut c: *mut client) {
    if !((*c).jobs).is_null() {
        format_job_tidy((*c).jobs, 1 as libc::c_int);
    }
    free((*c).jobs as *mut libc::c_void);
}
unsafe extern "C" fn format_printf(
    mut fmt: *const libc::c_char,
    mut args: ...
) -> *mut libc::c_char {
    let mut ap: ::core::ffi::VaListImpl;
    let mut s: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    ap = args.clone();
    xvasprintf(&mut s, fmt, ap.as_va_list());
    return s;
}
unsafe extern "C" fn format_cb_host(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut host: [libc::c_char; 65] = [0; 65];
    if gethostname(
        host.as_mut_ptr(),
        ::core::mem::size_of::<[libc::c_char; 65]>() as libc::c_ulong,
    ) != 0 as libc::c_int
    {
        return xstrdup(b"\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return xstrdup(host.as_mut_ptr()) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_host_short(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut host: [libc::c_char; 65] = [0; 65];
    let mut cp: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if gethostname(
        host.as_mut_ptr(),
        ::core::mem::size_of::<[libc::c_char; 65]>() as libc::c_ulong,
    ) != 0 as libc::c_int
    {
        return xstrdup(b"\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    cp = strchr(host.as_mut_ptr(), '.' as i32);
    if !cp.is_null() {
        *cp = '\0' as i32 as libc::c_char;
    }
    return xstrdup(host.as_mut_ptr()) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pid(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%ld\0" as *const u8 as *const libc::c_char,
        getpid() as libc::c_long,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_session_attached_list(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut s: *mut session = (*ft).s;
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = evbuffer_new();
    if buffer.is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    loop_0 = clients.tqh_first;
    while !loop_0.is_null() {
        if (*loop_0).session == s {
            if evbuffer_get_length(buffer) > 0 as libc::c_int as libc::c_ulong {
                evbuffer_add(
                    buffer,
                    b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                    1 as libc::c_int as size_t,
                );
            }
            evbuffer_add_printf(
                buffer,
                b"%s\0" as *const u8 as *const libc::c_char,
                (*loop_0).name,
            );
        }
        loop_0 = (*loop_0).entry.tqe_next;
    }
    size = evbuffer_get_length(buffer) as libc::c_int;
    if size != 0 as libc::c_int {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            size,
            evbuffer_pullup(buffer, -(1 as libc::c_int) as ssize_t),
        );
    }
    evbuffer_free(buffer);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_session_alerts(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = (*ft).s;
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut alerts: [libc::c_char; 1024] = [0; 1024];
    let mut tmp: [libc::c_char; 16] = [0; 16];
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    *alerts.as_mut_ptr() = '\0' as i32 as libc::c_char;
    wl = winlinks_RB_MINMAX(&mut (*s).windows, -(1 as libc::c_int));
    while !wl.is_null() {
        if (*wl).flags & (0x1 as libc::c_int | 0x2 as libc::c_int | 0x4 as libc::c_int)
            != 0 as libc::c_int
        {
            xsnprintf(
                tmp.as_mut_ptr(),
                ::core::mem::size_of::<[libc::c_char; 16]>() as libc::c_ulong,
                b"%u\0" as *const u8 as *const libc::c_char,
                (*wl).idx,
            );
            if *alerts.as_mut_ptr() as libc::c_int != '\0' as i32 {
                strlcat(
                    alerts.as_mut_ptr(),
                    b",\0" as *const u8 as *const libc::c_char,
                    ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
                );
            }
            strlcat(
                alerts.as_mut_ptr(),
                tmp.as_mut_ptr(),
                ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
            );
            if (*wl).flags & 0x2 as libc::c_int != 0 {
                strlcat(
                    alerts.as_mut_ptr(),
                    b"#\0" as *const u8 as *const libc::c_char,
                    ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
                );
            }
            if (*wl).flags & 0x1 as libc::c_int != 0 {
                strlcat(
                    alerts.as_mut_ptr(),
                    b"!\0" as *const u8 as *const libc::c_char,
                    ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
                );
            }
            if (*wl).flags & 0x4 as libc::c_int != 0 {
                strlcat(
                    alerts.as_mut_ptr(),
                    b"~\0" as *const u8 as *const libc::c_char,
                    ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
                );
            }
        }
        wl = winlinks_RB_NEXT(wl);
    }
    return xstrdup(alerts.as_mut_ptr()) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_session_stack(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = (*ft).s;
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut result: [libc::c_char; 1024] = [0; 1024];
    let mut tmp: [libc::c_char; 16] = [0; 16];
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    xsnprintf(
        result.as_mut_ptr(),
        ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
        b"%u\0" as *const u8 as *const libc::c_char,
        (*(*s).curw).idx,
    );
    wl = (*s).lastw.tqh_first;
    while !wl.is_null() {
        xsnprintf(
            tmp.as_mut_ptr(),
            ::core::mem::size_of::<[libc::c_char; 16]>() as libc::c_ulong,
            b"%u\0" as *const u8 as *const libc::c_char,
            (*wl).idx,
        );
        if *result.as_mut_ptr() as libc::c_int != '\0' as i32 {
            strlcat(
                result.as_mut_ptr(),
                b",\0" as *const u8 as *const libc::c_char,
                ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
            );
        }
        strlcat(
            result.as_mut_ptr(),
            tmp.as_mut_ptr(),
            ::core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
        );
        wl = (*wl).sentry.tqe_next;
    }
    return xstrdup(result.as_mut_ptr()) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_stack_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = std::ptr::null_mut::<session>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut idx: u_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if ((*ft).wl).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    s = (*(*ft).wl).session;
    idx = 0 as libc::c_int as u_int;
    wl = (*s).lastw.tqh_first;
    while !wl.is_null() {
        idx = idx.wrapping_add(1);
        if wl == (*ft).wl {
            break;
        }
        wl = (*wl).sentry.tqe_next;
    }
    if wl.is_null() {
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%u\0" as *const u8 as *const libc::c_char,
        idx,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_linked_sessions_list(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if ((*ft).wl).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = (*(*ft).wl).window;
    buffer = evbuffer_new();
    if buffer.is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    wl = (*w).winlinks.tqh_first;
    while !wl.is_null() {
        if evbuffer_get_length(buffer) > 0 as libc::c_int as libc::c_ulong {
            evbuffer_add(
                buffer,
                b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                1 as libc::c_int as size_t,
            );
        }
        evbuffer_add_printf(
            buffer,
            b"%s\0" as *const u8 as *const libc::c_char,
            (*(*wl).session).name,
        );
        wl = (*wl).wentry.tqe_next;
    }
    size = evbuffer_get_length(buffer) as libc::c_int;
    if size != 0 as libc::c_int {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            size,
            evbuffer_pullup(buffer, -(1 as libc::c_int) as ssize_t),
        );
    }
    evbuffer_free(buffer);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_active_sessions(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut n: u_int = 0 as libc::c_int as u_int;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if ((*ft).wl).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = (*(*ft).wl).window;
    wl = (*w).winlinks.tqh_first;
    while !wl.is_null() {
        if (*(*wl).session).curw == wl {
            n = n.wrapping_add(1);
        }
        wl = (*wl).wentry.tqe_next;
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%u\0" as *const u8 as *const libc::c_char,
        n,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_active_sessions_list(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if ((*ft).wl).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = (*(*ft).wl).window;
    buffer = evbuffer_new();
    if buffer.is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    wl = (*w).winlinks.tqh_first;
    while !wl.is_null() {
        if (*(*wl).session).curw == wl {
            if evbuffer_get_length(buffer) > 0 as libc::c_int as libc::c_ulong {
                evbuffer_add(
                    buffer,
                    b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                    1 as libc::c_int as size_t,
                );
            }
            evbuffer_add_printf(
                buffer,
                b"%s\0" as *const u8 as *const libc::c_char,
                (*(*wl).session).name,
            );
        }
        wl = (*wl).wentry.tqe_next;
    }
    size = evbuffer_get_length(buffer) as libc::c_int;
    if size != 0 as libc::c_int {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            size,
            evbuffer_pullup(buffer, -(1 as libc::c_int) as ssize_t),
        );
    }
    evbuffer_free(buffer);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_active_clients(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut client_session: *mut session = std::ptr::null_mut::<session>();
    let mut n: u_int = 0 as libc::c_int as u_int;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if ((*ft).wl).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = (*(*ft).wl).window;
    loop_0 = clients.tqh_first;
    while !loop_0.is_null() {
        client_session = (*loop_0).session;
        if !client_session.is_null() {
            if w == (*(*client_session).curw).window {
                n = n.wrapping_add(1);
            }
        }
        loop_0 = (*loop_0).entry.tqe_next;
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%u\0" as *const u8 as *const libc::c_char,
        n,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_active_clients_list(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut client_session: *mut session = std::ptr::null_mut::<session>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if ((*ft).wl).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = (*(*ft).wl).window;
    buffer = evbuffer_new();
    if buffer.is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    loop_0 = clients.tqh_first;
    while !loop_0.is_null() {
        client_session = (*loop_0).session;
        if !client_session.is_null() {
            if w == (*(*client_session).curw).window {
                if evbuffer_get_length(buffer) > 0 as libc::c_int as libc::c_ulong {
                    evbuffer_add(
                        buffer,
                        b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                        1 as libc::c_int as size_t,
                    );
                }
                evbuffer_add_printf(
                    buffer,
                    b"%s\0" as *const u8 as *const libc::c_char,
                    (*loop_0).name,
                );
            }
        }
        loop_0 = (*loop_0).entry.tqe_next;
    }
    size = evbuffer_get_length(buffer) as libc::c_int;
    if size != 0 as libc::c_int {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            size,
            evbuffer_pullup(buffer, -(1 as libc::c_int) as ssize_t),
        );
    }
    evbuffer_free(buffer);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_layout(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = (*ft).w;
    if w.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if !((*w).saved_layout_root).is_null() {
        return layout_dump((*w).saved_layout_root) as *mut libc::c_void;
    }
    return layout_dump((*w).layout_root) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_visible_layout(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut w: *mut window = (*ft).w;
    if w.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    return layout_dump((*w).layout_root) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_start_command(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    return cmd_stringify_argv((*wp).argc, (*wp).argv) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_start_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if ((*wp).cwd).is_null() {
        return xstrdup(b"\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return xstrdup((*wp).cwd) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_current_command(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut cmd: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() || ((*wp).shell).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    cmd = osdep_get_name((*wp).fd, ((*wp).tty).as_mut_ptr());
    if cmd.is_null() || *cmd as libc::c_int == '\0' as i32 {
        free(cmd as *mut libc::c_void);
        cmd = cmd_stringify_argv((*wp).argc, (*wp).argv);
        if cmd.is_null() || *cmd as libc::c_int == '\0' as i32 {
            free(cmd as *mut libc::c_void);
            cmd = xstrdup((*wp).shell);
        }
    }
    value = parse_window_name(cmd);
    free(cmd as *mut libc::c_void);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_current_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut cwd: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    cwd = osdep_get_cwd((*wp).fd);
    if cwd.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    return xstrdup(cwd) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_history_bytes(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut gl: *mut grid_line = std::ptr::null_mut::<grid_line>();
    let mut size: size_t = 0 as libc::c_int as size_t;
    let mut i: u_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = (*wp).base.grid;
    i = 0 as libc::c_int as u_int;
    while i < ((*gd).hsize).wrapping_add((*gd).sy) {
        gl = grid_get_line(gd, i);
        size = (size as libc::c_ulong).wrapping_add(
            ((*gl).cellsize as libc::c_ulong)
                .wrapping_mul(::core::mem::size_of::<grid_cell_entry>() as libc::c_ulong),
        ) as size_t as size_t;
        size = (size as libc::c_ulong).wrapping_add(
            ((*gl).extdsize as libc::c_ulong)
                .wrapping_mul(::core::mem::size_of::<grid_extd_entry>() as libc::c_ulong),
        ) as size_t as size_t;
        i = i.wrapping_add(1);
    }
    size = (size as libc::c_ulong).wrapping_add(
        (((*gd).hsize).wrapping_add((*gd).sy) as libc::c_ulong)
            .wrapping_mul(::core::mem::size_of::<grid_line>() as libc::c_ulong),
    ) as size_t as size_t;
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%zu\0" as *const u8 as *const libc::c_char,
        size,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_history_all_bytes(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut gl: *mut grid_line = std::ptr::null_mut::<grid_line>();
    let mut i: u_int = 0;
    let mut lines: u_int = 0;
    let mut cells: u_int = 0 as libc::c_int as u_int;
    let mut extended_cells: u_int = 0 as libc::c_int as u_int;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = (*wp).base.grid;
    lines = ((*gd).hsize).wrapping_add((*gd).sy);
    i = 0 as libc::c_int as u_int;
    while i < lines {
        gl = grid_get_line(gd, i);
        cells = (cells as libc::c_uint).wrapping_add((*gl).cellsize) as u_int as u_int;
        extended_cells =
            (extended_cells as libc::c_uint).wrapping_add((*gl).extdsize) as u_int as u_int;
        i = i.wrapping_add(1);
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%u,%zu,%u,%zu,%u,%zu\0" as *const u8 as *const libc::c_char,
        lines,
        (lines as libc::c_ulong).wrapping_mul(::core::mem::size_of::<grid_line>() as libc::c_ulong),
        cells,
        (cells as libc::c_ulong)
            .wrapping_mul(::core::mem::size_of::<grid_cell_entry>() as libc::c_ulong),
        extended_cells,
        (extended_cells as libc::c_ulong)
            .wrapping_mul(::core::mem::size_of::<grid_extd_entry>() as libc::c_ulong),
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pane_tabs(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut i: u_int = 0;
    let mut size: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = evbuffer_new();
    if buffer.is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    i = 0 as libc::c_int as u_int;
    while i < (*(*wp).base.grid).sx {
        if *((*wp).base.tabs).offset((i >> 3 as libc::c_int) as isize) as libc::c_int
            & (1 as libc::c_int) << (i & 0x7 as libc::c_int as libc::c_uint)
            != 0
        {
            if evbuffer_get_length(buffer) > 0 as libc::c_int as libc::c_ulong {
                evbuffer_add(
                    buffer,
                    b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                    1 as libc::c_int as size_t,
                );
            }
            evbuffer_add_printf(buffer, b"%u\0" as *const u8 as *const libc::c_char, i);
        }
        i = i.wrapping_add(1);
    }
    size = evbuffer_get_length(buffer) as libc::c_int;
    if size != 0 as libc::c_int {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            size,
            evbuffer_pullup(buffer, -(1 as libc::c_int) as ssize_t),
        );
    }
    evbuffer_free(buffer);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pane_fg(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    tty_default_colours(&mut gc, wp);
    return xstrdup(colour_tostring(gc.fg)) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pane_bg(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    tty_default_colours(&mut gc, wp);
    return xstrdup(colour_tostring(gc.bg)) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_session_group_list(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = (*ft).s;
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    let mut loop_0: *mut session = std::ptr::null_mut::<session>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    sg = session_group_contains(s);
    if sg.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = evbuffer_new();
    if buffer.is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    loop_0 = (*sg).sessions.tqh_first;
    while !loop_0.is_null() {
        if evbuffer_get_length(buffer) > 0 as libc::c_int as libc::c_ulong {
            evbuffer_add(
                buffer,
                b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                1 as libc::c_int as size_t,
            );
        }
        evbuffer_add_printf(
            buffer,
            b"%s\0" as *const u8 as *const libc::c_char,
            (*loop_0).name,
        );
        loop_0 = (*loop_0).gentry.tqe_next;
    }
    size = evbuffer_get_length(buffer) as libc::c_int;
    if size != 0 as libc::c_int {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            size,
            evbuffer_pullup(buffer, -(1 as libc::c_int) as ssize_t),
        );
    }
    evbuffer_free(buffer);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_session_group_attached_list(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut s: *mut session = (*ft).s;
    let mut client_session: *mut session = std::ptr::null_mut::<session>();
    let mut session_loop: *mut session = std::ptr::null_mut::<session>();
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    sg = session_group_contains(s);
    if sg.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = evbuffer_new();
    if buffer.is_null() {
        fatalx(b"out of memory\0" as *const u8 as *const libc::c_char);
    }
    loop_0 = clients.tqh_first;
    while !loop_0.is_null() {
        client_session = (*loop_0).session;
        if !client_session.is_null() {
            session_loop = (*sg).sessions.tqh_first;
            while !session_loop.is_null() {
                if session_loop == client_session {
                    if evbuffer_get_length(buffer) > 0 as libc::c_int as libc::c_ulong {
                        evbuffer_add(
                            buffer,
                            b",\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                            1 as libc::c_int as size_t,
                        );
                    }
                    evbuffer_add_printf(
                        buffer,
                        b"%s\0" as *const u8 as *const libc::c_char,
                        (*loop_0).name,
                    );
                }
                session_loop = (*session_loop).gentry.tqe_next;
            }
        }
        loop_0 = (*loop_0).entry.tqe_next;
    }
    size = evbuffer_get_length(buffer) as libc::c_int;
    if size != 0 as libc::c_int {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            size,
            evbuffer_pullup(buffer, -(1 as libc::c_int) as ssize_t),
        );
    }
    evbuffer_free(buffer);
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pane_in_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut n: u_int = 0 as libc::c_int as u_int;
    let mut wme: *mut window_mode_entry = std::ptr::null_mut::<window_mode_entry>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wme = (*wp).modes.tqh_first;
    while !wme.is_null() {
        n = n.wrapping_add(1);
        wme = (*wme).entry.tqe_next;
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%u\0" as *const u8 as *const libc::c_char,
        n,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pane_at_top(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut status: libc::c_int = 0;
    let mut flag: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = (*wp).window;
    status = options_get_number(
        (*w).options,
        b"pane-border-status\0" as *const u8 as *const libc::c_char,
    ) as libc::c_int;
    if status == 1 as libc::c_int {
        flag = ((*wp).yoff == 1 as libc::c_int as libc::c_uint) as libc::c_int;
    } else {
        flag = ((*wp).yoff == 0 as libc::c_int as libc::c_uint) as libc::c_int;
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%d\0" as *const u8 as *const libc::c_char,
        flag,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pane_at_bottom(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut status: libc::c_int = 0;
    let mut flag: libc::c_int = 0;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = (*wp).window;
    status = options_get_number(
        (*w).options,
        b"pane-border-status\0" as *const u8 as *const libc::c_char,
    ) as libc::c_int;
    if status == 2 as libc::c_int {
        flag = (((*wp).yoff).wrapping_add((*wp).sy)
            == ((*w).sy).wrapping_sub(1 as libc::c_int as libc::c_uint))
            as libc::c_int;
    } else {
        flag = (((*wp).yoff).wrapping_add((*wp).sy) == (*w).sy) as libc::c_int;
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%d\0" as *const u8 as *const libc::c_char,
        flag,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_cursor_character(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    grid_view_get_cell((*wp).base.grid, (*wp).base.cx, (*wp).base.cy, &mut gc);
    if !(gc.flags as libc::c_int) & 0x4 as libc::c_int != 0 {
        xasprintf(
            &mut value as *mut *mut libc::c_char,
            b"%.*s\0" as *const u8 as *const libc::c_char,
            gc.data.size as libc::c_int,
            (gc.data.data).as_mut_ptr(),
        );
    }
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_mouse_word(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (*ft).m.valid == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = cmd_mouse_pane(
        &mut (*ft).m,
        std::ptr::null_mut::<*mut session>(),
        std::ptr::null_mut::<*mut winlink>(),
    );
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as libc::c_int) != 0 as libc::c_int {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if !((*wp).modes.tqh_first).is_null() {
        if window_pane_mode(wp) != 0 as libc::c_int {
            return window_copy_get_word(wp, x, y) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = (*wp).base.grid;
    return format_grid_word(gd, x, ((*gd).hsize).wrapping_add(y)) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_mouse_hyperlink(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (*ft).m.valid == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = cmd_mouse_pane(
        &mut (*ft).m,
        std::ptr::null_mut::<*mut session>(),
        std::ptr::null_mut::<*mut winlink>(),
    );
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as libc::c_int) != 0 as libc::c_int {
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = (*wp).base.grid;
    return format_grid_hyperlink(gd, x, ((*gd).hsize).wrapping_add(y), (*wp).screen)
        as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_mouse_line(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (*ft).m.valid == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = cmd_mouse_pane(
        &mut (*ft).m,
        std::ptr::null_mut::<*mut session>(),
        std::ptr::null_mut::<*mut winlink>(),
    );
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as libc::c_int) != 0 as libc::c_int {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if !((*wp).modes.tqh_first).is_null() {
        if window_pane_mode(wp) != 0 as libc::c_int {
            return window_copy_get_line(wp, y) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = (*wp).base.grid;
    return format_grid_line(gd, ((*gd).hsize).wrapping_add(y)) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_mouse_status_line(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut y: u_int = 0;
    if (*ft).m.valid == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if ((*ft).c).is_null() || !(*(*ft).c).tty.flags & 0x10 as libc::c_int != 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (*ft).m.statusat == 0 as libc::c_int && (*ft).m.y < (*ft).m.statuslines {
        y = (*ft).m.y;
    } else if (*ft).m.statusat > 0 as libc::c_int && (*ft).m.y >= (*ft).m.statusat as u_int {
        y = ((*ft).m.y).wrapping_sub((*ft).m.statusat as libc::c_uint);
    } else {
        return std::ptr::null_mut::<libc::c_void>();
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%u\0" as *const u8 as *const libc::c_char,
        y,
    );
    return value as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_mouse_status_range(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sr: *mut style_range = std::ptr::null_mut::<style_range>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (*ft).m.valid == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if ((*ft).c).is_null() || !(*(*ft).c).tty.flags & 0x10 as libc::c_int != 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (*ft).m.statusat == 0 as libc::c_int && (*ft).m.y < (*ft).m.statuslines {
        x = (*ft).m.x;
        y = (*ft).m.y;
    } else if (*ft).m.statusat > 0 as libc::c_int && (*ft).m.y >= (*ft).m.statusat as u_int {
        x = (*ft).m.x;
        y = ((*ft).m.y).wrapping_sub((*ft).m.statusat as libc::c_uint);
    } else {
        return std::ptr::null_mut::<libc::c_void>();
    }
    sr = status_get_range((*ft).c, x, y);
    if sr.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    match (*sr).type_0 as libc::c_uint {
        0 => return std::ptr::null_mut::<libc::c_void>(),
        1 => {
            return xstrdup(b"left\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        2 => {
            return xstrdup(b"right\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        3 => {
            return xstrdup(b"pane\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        4 => {
            return xstrdup(b"window\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        5 => {
            return xstrdup(b"session\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        6 => return xstrdup(((*sr).string).as_mut_ptr()) as *mut libc::c_void,
        _ => {}
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_alternate_on(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if !((*(*ft).wp).base.saved_grid).is_null() {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_alternate_saved_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).base.saved_cx,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_alternate_saved_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).base.saved_cy,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_buffer_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).pb).is_null() {
        return xstrdup(paste_buffer_name((*ft).pb)) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_buffer_sample(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).pb).is_null() {
        return paste_make_sample((*ft).pb) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_buffer_size(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut size: size_t = 0;
    if !((*ft).pb).is_null() {
        paste_buffer_data((*ft).pb, &mut size);
        return format_printf(b"%zu\0" as *const u8 as *const libc::c_char, size)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_cell_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() && (*(*ft).c).tty.flags & 0x10 as libc::c_int != 0 {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).c).tty.ypixel,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_cell_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() && (*(*ft).c).tty.flags & 0x10 as libc::c_int != 0 {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).c).tty.xpixel,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_control_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        if (*(*ft).c).flags & 0x2000 as libc::c_int as libc::c_ulong != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_discarded(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return format_printf(
            b"%zu\0" as *const u8 as *const libc::c_char,
            (*(*ft).c).discarded,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_flags(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return xstrdup(server_client_get_flags((*ft).c)) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() && (*(*ft).c).tty.flags & 0x10 as libc::c_int != 0 {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).c).tty.sy,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_key_table(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return xstrdup((*(*(*ft).c).keytable).name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_last_session(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null()
        && !((*(*ft).c).last_session).is_null()
        && session_alive((*(*ft).c).last_session) != 0
    {
        return xstrdup((*(*(*ft).c).last_session).name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return xstrdup((*(*ft).c).name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_pid(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return format_printf(
            b"%ld\0" as *const u8 as *const libc::c_char,
            (*(*ft).c).pid as libc::c_long,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_prefix(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut name: *const libc::c_char = std::ptr::null::<libc::c_char>();
    if !((*ft).c).is_null() {
        name = server_client_get_key_table((*ft).c);
        if strcmp((*(*(*ft).c).keytable).name, name) == 0 as libc::c_int {
            return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_readonly(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        if (*(*ft).c).flags & 0x800 as libc::c_int as libc::c_ulong != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_session(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() && !((*(*ft).c).session).is_null() {
        return xstrdup((*(*(*ft).c).session).name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_termfeatures(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return xstrdup(tty_get_features((*(*ft).c).term_features)) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_termname(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return xstrdup((*(*ft).c).term_name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_termtype(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        if ((*(*ft).c).term_type).is_null() {
            return xstrdup(b"\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup((*(*ft).c).term_type) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_tty(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return xstrdup((*(*ft).c).ttyname) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_uid(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut uid: uid_t = 0;
    if !((*ft).c).is_null() {
        uid = proc_get_peer_uid((*(*ft).c).peer);
        if uid != -(1 as libc::c_int) as uid_t {
            return format_printf(
                b"%ld\0" as *const u8 as *const libc::c_char,
                uid as libc::c_long,
            ) as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_user(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut uid: uid_t = 0;
    let mut pw: *mut passwd = std::ptr::null_mut::<passwd>();
    if !((*ft).c).is_null() {
        uid = proc_get_peer_uid((*(*ft).c).peer);
        if uid != -(1 as libc::c_int) as uid_t && {
            pw = getpwuid(uid);
            !pw.is_null()
        } {
            return xstrdup((*pw).pw_name) as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_utf8(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        if (*(*ft).c).flags & 0x10000 as libc::c_int as libc::c_ulong != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).c).tty.sx,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_written(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return format_printf(
            b"%zu\0" as *const u8 as *const libc::c_char,
            (*(*ft).c).written,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_config_files(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut slen: size_t = 0 as libc::c_int as size_t;
    let mut i: u_int = 0;
    let mut n: size_t = 0;
    i = 0 as libc::c_int as u_int;
    while i < cfg_nfiles {
        n = (strlen(*cfg_files.offset(i as isize))).wrapping_add(1 as libc::c_int as libc::c_ulong);
        s = xrealloc(
            s as *mut libc::c_void,
            slen.wrapping_add(n)
                .wrapping_add(1 as libc::c_int as libc::c_ulong),
        ) as *mut libc::c_char;
        slen = (slen as libc::c_ulong).wrapping_add(xsnprintf(
            s.offset(slen as isize),
            n.wrapping_add(1 as libc::c_int as libc::c_ulong),
            b"%s,\0" as *const u8 as *const libc::c_char,
            *cfg_files.offset(i as isize),
        ) as libc::c_ulong) as size_t as size_t;
        i = i.wrapping_add(1);
    }
    if s.is_null() {
        return xstrdup(b"\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    *s.offset(slen.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize) =
        '\0' as i32 as libc::c_char;
    return s as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_cursor_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x1 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_cursor_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).base.cx,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_cursor_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).base.cy,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_history_limit(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*(*ft).wp).base.grid).hlimit,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_history_size(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*(*ft).wp).base.grid).hsize,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_insert_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x2 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_keypad_cursor_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x4 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_keypad_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x8 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_all_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x1000 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_any_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode
            & (0x20 as libc::c_int | 0x40 as libc::c_int | 0x1000 as libc::c_int)
            != 0
        {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_button_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x40 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_pane(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    if (*ft).m.valid != 0 {
        wp = cmd_mouse_pane(
            &mut (*ft).m,
            std::ptr::null_mut::<*mut session>(),
            std::ptr::null_mut::<*mut winlink>(),
        );
        if !wp.is_null() {
            return format_printf(b"%%%u\0" as *const u8 as *const libc::c_char, (*wp).id)
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_sgr_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x200 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_standard_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x20 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_utf8_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x100 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (*ft).m.valid == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = cmd_mouse_pane(
        &mut (*ft).m,
        std::ptr::null_mut::<*mut session>(),
        std::ptr::null_mut::<*mut winlink>(),
    );
    if !wp.is_null()
        && cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as libc::c_int) == 0 as libc::c_int
    {
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, x) as *mut libc::c_void;
    }
    if !((*ft).c).is_null() && (*(*ft).c).tty.flags & 0x10 as libc::c_int != 0 {
        if (*ft).m.statusat == 0 as libc::c_int && (*ft).m.y < (*ft).m.statuslines {
            return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*ft).m.x)
                as *mut libc::c_void;
        }
        if (*ft).m.statusat > 0 as libc::c_int && (*ft).m.y >= (*ft).m.statusat as u_int {
            return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*ft).m.x)
                as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_mouse_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (*ft).m.valid == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = cmd_mouse_pane(
        &mut (*ft).m,
        std::ptr::null_mut::<*mut session>(),
        std::ptr::null_mut::<*mut winlink>(),
    );
    if !wp.is_null()
        && cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as libc::c_int) == 0 as libc::c_int
    {
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, y) as *mut libc::c_void;
    }
    if !((*ft).c).is_null() && (*(*ft).c).tty.flags & 0x10 as libc::c_int != 0 {
        if (*ft).m.statusat == 0 as libc::c_int && (*ft).m.y < (*ft).m.statuslines {
            return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*ft).m.y)
                as *mut libc::c_void;
        }
        if (*ft).m.statusat > 0 as libc::c_int && (*ft).m.y >= (*ft).m.statusat as u_int {
            return format_printf(
                b"%u\0" as *const u8 as *const libc::c_char,
                ((*ft).m.y).wrapping_sub((*ft).m.statusat as libc::c_uint),
            ) as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_next_session_id(mut ft: *mut format_tree) -> *mut libc::c_void {
    return format_printf(
        b"$%u\0" as *const u8 as *const libc::c_char,
        next_session_id,
    ) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_origin_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x2000 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_active(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*ft).wp == (*(*(*ft).wp).window).active {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_at_left(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).xoff == 0 as libc::c_int as libc::c_uint {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_at_right(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if ((*(*ft).wp).xoff).wrapping_add((*(*ft).wp).sx) == (*(*(*ft).wp).window).sx {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_bottom(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            ((*(*ft).wp).yoff)
                .wrapping_add((*(*ft).wp).sy)
                .wrapping_sub(1 as libc::c_int as libc::c_uint),
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_dead(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).fd == -(1 as libc::c_int) {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_dead_signal(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    let mut name: *const libc::c_char = std::ptr::null::<libc::c_char>();
    if !wp.is_null() {
        if (*wp).flags & 0x200 as libc::c_int != 0
            && (((*wp).status & 0x7f as libc::c_int) + 1 as libc::c_int) as libc::c_schar
                as libc::c_int
                >> 1 as libc::c_int
                > 0 as libc::c_int
        {
            name = sig2name((*wp).status & 0x7f as libc::c_int);
            return format_printf(b"%s\0" as *const u8 as *const libc::c_char, name)
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_dead_status(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    if !wp.is_null() {
        if (*wp).flags & 0x200 as libc::c_int != 0
            && (*wp).status & 0x7f as libc::c_int == 0 as libc::c_int
        {
            return format_printf(
                b"%d\0" as *const u8 as *const libc::c_char,
                ((*wp).status & 0xff00 as libc::c_int) >> 8 as libc::c_int,
            ) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_dead_time(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = (*ft).wp;
    if !wp.is_null() {
        if (*wp).flags & 0x400 as libc::c_int != 0 {
            return &mut (*wp).dead_time as *mut timeval as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    if (*ft).type_0 as libc::c_uint == FORMAT_TYPE_PANE as libc::c_int as libc::c_uint {
        return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_pane_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*(*ft).wp).sy)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_id(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%%%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).id,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut idx: u_int = 0;
    if !((*ft).wp).is_null() && window_pane_index((*ft).wp, &mut idx) == 0 as libc::c_int {
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, idx)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_input_off(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).flags & 0x40 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_unseen_changes(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).flags & 0x2000 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_key_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() && !((*(*ft).wp).screen).is_null() {
        match (*(*(*ft).wp).screen).mode & (0x8000 as libc::c_int | 0x40000 as libc::c_int) {
            32768 => {
                return xstrdup(b"Ext 1\0" as *const u8 as *const libc::c_char)
                    as *mut libc::c_void;
            }
            262144 => {
                return xstrdup(b"Ext 2\0" as *const u8 as *const libc::c_char)
                    as *mut libc::c_void;
            }
            _ => {
                return xstrdup(b"VT10x\0" as *const u8 as *const libc::c_char)
                    as *mut libc::c_void;
            }
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_last(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*ft).wp == (*(*(*ft).wp).window).last_panes.tqh_first {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_left(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).xoff,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_marked(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if server_check_marked() != 0 && marked_pane.wp == (*ft).wp {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_marked_set(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if server_check_marked() != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wme: *mut window_mode_entry = std::ptr::null_mut::<window_mode_entry>();
    if !((*ft).wp).is_null() {
        wme = (*(*ft).wp).modes.tqh_first;
        if !wme.is_null() {
            return xstrdup((*(*wme).mode).name) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if ((*(*ft).wp).base.path).is_null() {
            return xstrdup(b"\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup((*(*ft).wp).base.path) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_pid(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%ld\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).pid as libc::c_long,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_pipe(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).pipe_fd != -(1 as libc::c_int) {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_right(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            ((*(*ft).wp).xoff)
                .wrapping_add((*(*ft).wp).sx)
                .wrapping_sub(1 as libc::c_int as libc::c_uint),
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_search_string(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if ((*(*ft).wp).searchstr).is_null() {
            return xstrdup(b"\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup((*(*ft).wp).searchstr) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_synchronized(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if options_get_number(
            (*(*ft).wp).options,
            b"synchronize-panes\0" as *const u8 as *const libc::c_char,
        ) != 0
        {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_title(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return xstrdup((*(*ft).wp).base.title) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_top(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).yoff,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_tty(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return xstrdup(((*(*ft).wp).tty).as_mut_ptr()) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_pane_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*(*ft).wp).sx)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_scroll_region_lower(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).base.rlower,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_scroll_region_upper(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).wp).base.rupper,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_server_sessions(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = std::ptr::null_mut::<session>();
    let mut n: u_int = 0 as libc::c_int as u_int;
    s = sessions_RB_MINMAX(&mut sessions, -(1 as libc::c_int));
    while !s.is_null() {
        n = n.wrapping_add(1);
        s = sessions_RB_NEXT(s);
    }
    return format_printf(b"%u\0" as *const u8 as *const libc::c_char, n) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_session_attached(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).s).attached,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    if (*ft).type_0 as libc::c_uint == FORMAT_TYPE_SESSION as libc::c_int as libc::c_uint {
        return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_session_group(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !((*ft).s).is_null() && {
        sg = session_group_contains((*ft).s);
        !sg.is_null()
    } {
        return xstrdup((*sg).name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_group_attached(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !((*ft).s).is_null() && {
        sg = session_group_contains((*ft).s);
        !sg.is_null()
    } {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            session_group_attached_count(sg),
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_group_many_attached(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !((*ft).s).is_null() && {
        sg = session_group_contains((*ft).s);
        !sg.is_null()
    } {
        if session_group_attached_count(sg) > 1 as libc::c_int as libc::c_uint {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_group_size(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !((*ft).s).is_null() && {
        sg = session_group_contains((*ft).s);
        !sg.is_null()
    } {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            session_group_count(sg),
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_grouped(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        if !(session_group_contains((*ft).s)).is_null() {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_id(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return format_printf(b"$%u\0" as *const u8 as *const libc::c_char, (*(*ft).s).id)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_many_attached(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        if (*(*ft).s).attached > 1 as libc::c_int as libc::c_uint {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_marked(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        if server_check_marked() != 0 && marked_pane.s == (*ft).s {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return xstrdup((*(*ft).s).name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return xstrdup((*(*ft).s).cwd) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_windows(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            winlink_count(&mut (*(*ft).s).windows),
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_socket_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    return xstrdup(socket_path) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_version(mut ft: *mut format_tree) -> *mut libc::c_void {
    return xstrdup(getversion()) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_sixel_support(mut ft: *mut format_tree) -> *mut libc::c_void {
    return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_active_window_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*(*ft).s).curw).idx,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_last_window_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    if !((*ft).s).is_null() {
        wl = winlinks_RB_MINMAX(&mut (*(*ft).s).windows, 1 as libc::c_int);
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*wl).idx)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_active(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if (*ft).wl == (*(*(*ft).wl).session).curw {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_activity_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if (*(*ft).wl).flags & 0x2 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_bell_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if (*(*ft).wl).flags & 0x1 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_bigger(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut ox: u_int = 0;
    let mut oy: u_int = 0;
    let mut sx: u_int = 0;
    let mut sy: u_int = 0;
    if !((*ft).c).is_null() {
        if tty_window_offset(&mut (*(*ft).c).tty, &mut ox, &mut oy, &mut sx, &mut sy) != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_cell_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).w).ypixel,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_cell_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*ft).w).xpixel,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_end_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if (*ft).wl == winlinks_RB_MINMAX(&mut (*(*(*ft).wl).session).windows, 1 as libc::c_int) {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_flags(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        return xstrdup(window_printable_flags((*ft).wl, 1 as libc::c_int)) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    if (*ft).type_0 as libc::c_uint == FORMAT_TYPE_WINDOW as libc::c_int as libc::c_uint {
        return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*(*ft).w).sy)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_id(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return format_printf(b"@%u\0" as *const u8 as *const libc::c_char, (*(*ft).w).id)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        return format_printf(b"%d\0" as *const u8 as *const libc::c_char, (*(*ft).wl).idx)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_last_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if (*ft).wl == (*(*(*ft).wl).session).lastw.tqh_first {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_linked(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if session_is_linked((*(*ft).wl).session, (*(*ft).wl).window) != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_linked_sessions(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            (*(*(*ft).wl).window).references,
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_marked_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if server_check_marked() != 0 && marked_pane.wl == (*ft).wl {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return format_printf(b"%s\0" as *const u8 as *const libc::c_char, (*(*ft).w).name)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_offset_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut ox: u_int = 0;
    let mut oy: u_int = 0;
    let mut sx: u_int = 0;
    let mut sy: u_int = 0;
    if !((*ft).c).is_null() {
        if tty_window_offset(&mut (*(*ft).c).tty, &mut ox, &mut oy, &mut sx, &mut sy) != 0 {
            return format_printf(b"%u\0" as *const u8 as *const libc::c_char, ox)
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_offset_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut ox: u_int = 0;
    let mut oy: u_int = 0;
    let mut sx: u_int = 0;
    let mut sy: u_int = 0;
    if !((*ft).c).is_null() {
        if tty_window_offset(&mut (*(*ft).c).tty, &mut ox, &mut oy, &mut sx, &mut sy) != 0 {
            return format_printf(b"%u\0" as *const u8 as *const libc::c_char, oy)
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_panes(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return format_printf(
            b"%u\0" as *const u8 as *const libc::c_char,
            window_count_panes((*ft).w),
        ) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_raw_flags(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        return xstrdup(window_printable_flags((*ft).wl, 0 as libc::c_int)) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_silence_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if (*(*ft).wl).flags & 0x4 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_start_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wl).is_null() {
        if (*ft).wl == winlinks_RB_MINMAX(&mut (*(*(*ft).wl).session).windows, -(1 as libc::c_int))
        {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return format_printf(b"%u\0" as *const u8 as *const libc::c_char, (*(*ft).w).sx)
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_window_zoomed_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        if (*(*ft).w).flags & 0x8 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_wrap_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).wp).is_null() {
        if (*(*ft).wp).base.mode & 0x10 as libc::c_int != 0 {
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
        }
        return xstrdup(b"0\0" as *const u8 as *const libc::c_char) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_buffer_created(mut ft: *mut format_tree) -> *mut libc::c_void {
    static mut tv: timeval = timeval {
        tv_sec: 0,
        tv_usec: 0,
    };
    if !((*ft).pb).is_null() {
        tv.tv_usec = 0 as libc::c_int as __suseconds_t;
        tv.tv_sec = tv.tv_usec;
        tv.tv_sec = paste_buffer_created((*ft).pb);
        return &mut tv as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_activity(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return &mut (*(*ft).c).activity_time as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_client_created(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).c).is_null() {
        return &mut (*(*ft).c).creation_time as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_activity(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return &mut (*(*ft).s).activity_time as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_created(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return &mut (*(*ft).s).creation_time as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_session_last_attached(
    mut ft: *mut format_tree,
) -> *mut libc::c_void {
    if !((*ft).s).is_null() {
        return &mut (*(*ft).s).last_attached_time as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_start_time(mut ft: *mut format_tree) -> *mut libc::c_void {
    return &mut start_time as *mut timeval as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_window_activity(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !((*ft).w).is_null() {
        return &mut (*(*ft).w).activity_time as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
unsafe extern "C" fn format_cb_buffer_mode_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    return xstrdup(window_buffer_mode.default_format) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_client_mode_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    return xstrdup(window_client_mode.default_format) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_tree_mode_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    return xstrdup(window_tree_mode.default_format) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_uid(mut ft: *mut format_tree) -> *mut libc::c_void {
    return format_printf(
        b"%ld\0" as *const u8 as *const libc::c_char,
        getuid() as libc::c_long,
    ) as *mut libc::c_void;
}
unsafe extern "C" fn format_cb_user(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut pw: *mut passwd = std::ptr::null_mut::<passwd>();
    pw = getpwuid(getuid());
    if !pw.is_null() {
        return xstrdup((*pw).pw_name) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
static mut format_table: [format_table_entry; 172] = unsafe {
    [
        {
            let mut init = format_table_entry {
                key: b"active_window_index\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_active_window_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"alternate_on\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_alternate_on
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"alternate_saved_x\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_alternate_saved_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"alternate_saved_y\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_alternate_saved_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_created\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_buffer_created
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_mode_format\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_mode_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_name\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_sample\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_sample
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_size\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_size
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_activity\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_client_activity
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_cell_height\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_cell_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_cell_width\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_cell_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_control_mode\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_control_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_created\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_client_created
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_discarded\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_discarded
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_flags\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_flags
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_height\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_key_table\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_key_table
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_last_session\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_last_session
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_mode_format\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_mode_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_name\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_pid\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_pid
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_prefix\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_prefix
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_readonly\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_readonly
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_session\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_session
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_termfeatures\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_termfeatures
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_termname\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_termname
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_termtype\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_termtype
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_tty\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_tty
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_uid\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_uid
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_user\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_user
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_utf8\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_utf8
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_width\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_written\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_written
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"config_files\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_config_files
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_character\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_character
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_x\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_y\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_all_bytes\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_all_bytes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_bytes\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_bytes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_limit\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_limit
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_size\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_size
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"host\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_host as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"host_short\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_host_short
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"insert_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_insert_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"keypad_cursor_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_keypad_cursor_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"keypad_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_keypad_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"last_window_index\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_last_window_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_all_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_all_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_any_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_any_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_button_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_button_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_hyperlink\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_hyperlink
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_line\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_line
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_pane\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_pane
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_sgr_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_sgr_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_standard_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_standard_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_status_line\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_status_line
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_status_range\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_status_range
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_utf8_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_utf8_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_word\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_word
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_x\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_y\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"next_session_id\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_next_session_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"origin_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_origin_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_active\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_active
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_bottom\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_bottom
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_left\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_left
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_right\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_right
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_top\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_top
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_bg\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_bg
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_bottom\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_bottom
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_current_command\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_current_command
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_current_path\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_current_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_dead
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead_signal\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_dead_signal
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead_status\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_dead_status
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead_time\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_pane_dead_time
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_fg\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_fg
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_format\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_height\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_id\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_in_mode\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_in_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_index\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_input_off\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_input_off
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_key_mode\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_key_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_last\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_last
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_left\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_left
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_marked\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_marked
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_marked_set\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_marked_set
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_mode\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_path\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_pid\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_pid
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_pipe\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_pipe
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_right\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_right
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_search_string\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_search_string
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_start_command\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_start_command
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_start_path\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_start_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_synchronized\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_synchronized
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_tabs\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_tabs
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_title\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_title
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_top\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_top
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_tty\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_tty
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_unseen_changes\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_unseen_changes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_width\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pid\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pid as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"scroll_region_lower\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_scroll_region_lower
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"scroll_region_upper\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_scroll_region_upper
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"server_sessions\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_server_sessions
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_activity\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_session_activity
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_alerts\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_alerts
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_attached\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_attached_list\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_attached_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_created\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_session_created
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_format\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_attached\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_attached_list\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_attached_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_list\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_many_attached\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_many_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_size\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_size
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_grouped\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_grouped
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_id\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_last_attached\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_session_last_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_many_attached\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_many_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_marked\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_marked
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_name\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_path\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_stack\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_stack
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_windows\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_windows
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"sixel_support\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_sixel_support
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"socket_path\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_socket_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"start_time\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_start_time
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"tree_mode_format\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_tree_mode_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"uid\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_uid as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"user\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_user as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"version\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_version
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_clients\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_clients
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_clients_list\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_clients_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_sessions\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_sessions
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_sessions_list\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_sessions_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_activity\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_window_activity
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_activity_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_activity_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_bell_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_bell_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_bigger\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_bigger
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_cell_height\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_cell_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_cell_width\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_cell_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_end_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_end_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_flags\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_flags
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_format\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_height\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_id\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_index\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_last_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_last_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_layout\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_layout
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_linked\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_linked
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_linked_sessions\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_linked_sessions
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_linked_sessions_list\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_linked_sessions_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_marked_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_marked_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_name\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_offset_x\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_offset_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_offset_y\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_offset_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_panes\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_panes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_raw_flags\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_raw_flags
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_silence_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_silence_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_stack_index\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_stack_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_start_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_start_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_visible_layout\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_visible_layout
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_width\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_zoomed_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_zoomed_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"wrap_flag\0" as *const u8 as *const libc::c_char,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_wrap_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
    ]
};
unsafe extern "C" fn format_table_compare(
    mut key0: *const libc::c_void,
    mut entry0: *const libc::c_void,
) -> libc::c_int {
    let mut key: *const libc::c_char = key0 as *const libc::c_char;
    let mut entry: *const format_table_entry = entry0 as *const format_table_entry;
    return strcmp(key, (*entry).key);
}
unsafe extern "C" fn format_table_get(mut key: *const libc::c_char) -> *mut format_table_entry {
    return bsearch(
        key as *const libc::c_void,
        format_table.as_ptr() as *const libc::c_void,
        (::core::mem::size_of::<[format_table_entry; 172]>() as libc::c_ulong)
            .wrapping_div(::core::mem::size_of::<format_table_entry>() as libc::c_ulong),
        ::core::mem::size_of::<format_table_entry>() as libc::c_ulong,
        Some(
            format_table_compare
                as unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> libc::c_int,
        ),
    ) as *mut format_table_entry;
}
#[no_mangle]
pub unsafe extern "C" fn format_merge(mut ft: *mut format_tree, mut from: *mut format_tree) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = format_entry_tree_RB_MINMAX(&mut (*from).tree, -(1 as libc::c_int));
    while !fe.is_null() {
        if !((*fe).value).is_null() {
            format_add(
                ft,
                (*fe).key,
                b"%s\0" as *const u8 as *const libc::c_char,
                (*fe).value,
            );
        }
        fe = format_entry_tree_RB_NEXT(fe);
    }
}
#[no_mangle]
pub unsafe extern "C" fn format_get_pane(mut ft: *mut format_tree) -> *mut window_pane {
    return (*ft).wp;
}
unsafe extern "C" fn format_create_add_item(mut ft: *mut format_tree, mut item: *mut cmdq_item) {
    let mut event: *mut key_event = cmdq_get_event(item);
    let mut m: *mut mouse_event = &mut (*event).m;
    cmdq_merge_formats(item, ft);
    memcpy(
        &mut (*ft).m as *mut mouse_event as *mut libc::c_void,
        m as *const libc::c_void,
        ::core::mem::size_of::<mouse_event>() as libc::c_ulong,
    );
}
#[no_mangle]
pub unsafe extern "C" fn format_create(
    mut c: *mut client,
    mut item: *mut cmdq_item,
    mut tag: libc::c_int,
    mut flags: libc::c_int,
) -> *mut format_tree {
    let mut ft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    ft = xcalloc(
        1 as libc::c_int as size_t,
        ::core::mem::size_of::<format_tree>() as libc::c_ulong,
    ) as *mut format_tree;
    (*ft).tree.rbh_root = std::ptr::null_mut::<format_entry>();
    if !c.is_null() {
        (*ft).client = c;
        (*(*ft).client).references += 1;
    }
    (*ft).item = item;
    (*ft).tag = tag as u_int;
    (*ft).flags = flags;
    if !item.is_null() {
        format_create_add_item(ft, item);
    }
    return ft;
}
#[no_mangle]
pub unsafe extern "C" fn format_free(mut ft: *mut format_tree) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe1: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = format_entry_tree_RB_MINMAX(&mut (*ft).tree, -(1 as libc::c_int));
    while !fe.is_null() && {
        fe1 = format_entry_tree_RB_NEXT(fe);
        1 as libc::c_int != 0
    } {
        format_entry_tree_RB_REMOVE(&mut (*ft).tree, fe);
        free((*fe).value as *mut libc::c_void);
        free((*fe).key as *mut libc::c_void);
        free(fe as *mut libc::c_void);
        fe = fe1;
    }
    if !((*ft).client).is_null() {
        server_client_unref((*ft).client);
    }
    free(ft as *mut libc::c_void);
}
unsafe extern "C" fn format_log_debug_cb(
    mut key: *const libc::c_char,
    mut value: *const libc::c_char,
    mut arg: *mut libc::c_void,
) {
    let mut prefix: *const libc::c_char = arg as *const libc::c_char;
    log_debug(
        b"%s: %s=%s\0" as *const u8 as *const libc::c_char,
        prefix,
        key,
        value,
    );
}
#[no_mangle]
pub unsafe extern "C" fn format_log_debug(
    mut ft: *mut format_tree,
    mut prefix: *const libc::c_char,
) {
    format_each(
        ft,
        Some(
            format_log_debug_cb
                as unsafe extern "C" fn(
                    *const libc::c_char,
                    *const libc::c_char,
                    *mut libc::c_void,
                ) -> (),
        ),
        prefix as *mut libc::c_void,
    );
}
#[no_mangle]
pub unsafe extern "C" fn format_each(
    mut ft: *mut format_tree,
    mut cb: Option<
        unsafe extern "C" fn(*const libc::c_char, *const libc::c_char, *mut libc::c_void) -> (),
    >,
    mut arg: *mut libc::c_void,
) {
    let mut fte: *const format_table_entry = std::ptr::null::<format_table_entry>();
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut i: u_int = 0;
    let mut s: [libc::c_char; 64] = [0; 64];
    let mut value: *mut libc::c_void = std::ptr::null_mut::<libc::c_void>();
    let mut tv: *mut timeval = std::ptr::null_mut::<timeval>();
    i = 0 as libc::c_int as u_int;
    while (i as libc::c_ulong)
        < (::core::mem::size_of::<[format_table_entry; 172]>() as libc::c_ulong)
            .wrapping_div(::core::mem::size_of::<format_table_entry>() as libc::c_ulong)
    {
        fte = &*format_table.as_ptr().offset(i as isize) as *const format_table_entry;
        value = ((*fte).cb).expect("non-null function pointer")(ft);
        if !value.is_null() {
            if (*fte).type_0 as libc::c_uint == FORMAT_TABLE_TIME as libc::c_int as libc::c_uint {
                tv = value as *mut timeval;
                xsnprintf(
                    s.as_mut_ptr(),
                    ::core::mem::size_of::<[libc::c_char; 64]>() as libc::c_ulong,
                    b"%lld\0" as *const u8 as *const libc::c_char,
                    (*tv).tv_sec as libc::c_longlong,
                );
                cb.expect("non-null function pointer")((*fte).key, s.as_mut_ptr(), arg);
            } else {
                cb.expect("non-null function pointer")(
                    (*fte).key,
                    value as *const libc::c_char,
                    arg,
                );
                free(value);
            }
        }
        i = i.wrapping_add(1);
    }
    fe = format_entry_tree_RB_MINMAX(&mut (*ft).tree, -(1 as libc::c_int));
    while !fe.is_null() {
        if (*fe).time != 0 as libc::c_int as libc::c_long {
            xsnprintf(
                s.as_mut_ptr(),
                ::core::mem::size_of::<[libc::c_char; 64]>() as libc::c_ulong,
                b"%lld\0" as *const u8 as *const libc::c_char,
                (*fe).time as libc::c_longlong,
            );
            cb.expect("non-null function pointer")((*fe).key, s.as_mut_ptr(), arg);
        } else {
            if ((*fe).value).is_null() && ((*fe).cb).is_some() {
                (*fe).value =
                    ((*fe).cb).expect("non-null function pointer")(ft) as *mut libc::c_char;
                if ((*fe).value).is_null() {
                    (*fe).value = xstrdup(b"\0" as *const u8 as *const libc::c_char);
                }
            }
            cb.expect("non-null function pointer")((*fe).key, (*fe).value, arg);
        }
        fe = format_entry_tree_RB_NEXT(fe);
    }
}
#[no_mangle]
pub unsafe extern "C" fn format_add(
    mut ft: *mut format_tree,
    mut key: *const libc::c_char,
    mut fmt: *const libc::c_char,
    mut args: ...
) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_now: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut ap: ::core::ffi::VaListImpl;
    fe = xmalloc(::core::mem::size_of::<format_entry>() as libc::c_ulong) as *mut format_entry;
    (*fe).key = xstrdup(key);
    fe_now = format_entry_tree_RB_INSERT(&mut (*ft).tree, fe);
    if !fe_now.is_null() {
        free((*fe).key as *mut libc::c_void);
        free(fe as *mut libc::c_void);
        free((*fe_now).value as *mut libc::c_void);
        fe = fe_now;
    }
    (*fe).cb = None;
    (*fe).time = 0 as libc::c_int as time_t;
    ap = args.clone();
    xvasprintf(&mut (*fe).value, fmt, ap.as_va_list());
}
#[no_mangle]
pub unsafe extern "C" fn format_add_tv(
    mut ft: *mut format_tree,
    mut key: *const libc::c_char,
    mut tv: *mut timeval,
) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_now: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = xmalloc(::core::mem::size_of::<format_entry>() as libc::c_ulong) as *mut format_entry;
    (*fe).key = xstrdup(key);
    fe_now = format_entry_tree_RB_INSERT(&mut (*ft).tree, fe);
    if !fe_now.is_null() {
        free((*fe).key as *mut libc::c_void);
        free(fe as *mut libc::c_void);
        free((*fe_now).value as *mut libc::c_void);
        fe = fe_now;
    }
    (*fe).cb = None;
    (*fe).time = (*tv).tv_sec;
    (*fe).value = std::ptr::null_mut::<libc::c_char>();
}
#[no_mangle]
pub unsafe extern "C" fn format_add_cb(
    mut ft: *mut format_tree,
    mut key: *const libc::c_char,
    mut cb: format_cb,
) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_now: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = xmalloc(::core::mem::size_of::<format_entry>() as libc::c_ulong) as *mut format_entry;
    (*fe).key = xstrdup(key);
    fe_now = format_entry_tree_RB_INSERT(&mut (*ft).tree, fe);
    if !fe_now.is_null() {
        free((*fe).key as *mut libc::c_void);
        free(fe as *mut libc::c_void);
        free((*fe_now).value as *mut libc::c_void);
        fe = fe_now;
    }
    (*fe).cb = cb;
    (*fe).time = 0 as libc::c_int as time_t;
    (*fe).value = std::ptr::null_mut::<libc::c_char>();
}
unsafe extern "C" fn format_quote_shell(mut s: *const libc::c_char) -> *mut libc::c_char {
    let mut cp: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut at: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    out = xmalloc(
        (strlen(s))
            .wrapping_mul(2 as libc::c_int as libc::c_ulong)
            .wrapping_add(1 as libc::c_int as libc::c_ulong),
    ) as *mut libc::c_char;
    at = out;
    cp = s;
    while *cp as libc::c_int != '\0' as i32 {
        if !(strchr(
            b"|&;<>()$`\\\"'*?[# =%\0" as *const u8 as *const libc::c_char,
            *cp as libc::c_int,
        ))
        .is_null()
        {
            let fresh0 = at;
            at = at.offset(1);
            *fresh0 = '\\' as i32 as libc::c_char;
        }
        let fresh1 = at;
        at = at.offset(1);
        *fresh1 = *cp;
        cp = cp.offset(1);
    }
    *at = '\0' as i32 as libc::c_char;
    return out;
}
unsafe extern "C" fn format_quote_style(mut s: *const libc::c_char) -> *mut libc::c_char {
    let mut cp: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut at: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    out = xmalloc(
        (strlen(s))
            .wrapping_mul(2 as libc::c_int as libc::c_ulong)
            .wrapping_add(1 as libc::c_int as libc::c_ulong),
    ) as *mut libc::c_char;
    at = out;
    cp = s;
    while *cp as libc::c_int != '\0' as i32 {
        if *cp as libc::c_int == '#' as i32 {
            let fresh2 = at;
            at = at.offset(1);
            *fresh2 = '#' as i32 as libc::c_char;
        }
        let fresh3 = at;
        at = at.offset(1);
        *fresh3 = *cp;
        cp = cp.offset(1);
    }
    *at = '\0' as i32 as libc::c_char;
    return out;
}
#[no_mangle]
pub unsafe extern "C" fn format_pretty_time(
    mut t: time_t,
    mut seconds: libc::c_int,
) -> *mut libc::c_char {
    let mut now_tm: tm = tm {
        tm_sec: 0,
        tm_min: 0,
        tm_hour: 0,
        tm_mday: 0,
        tm_mon: 0,
        tm_year: 0,
        tm_wday: 0,
        tm_yday: 0,
        tm_isdst: 0,
        tm_gmtoff: 0,
        tm_zone: std::ptr::null::<libc::c_char>(),
    };
    let mut tm: tm = tm {
        tm_sec: 0,
        tm_min: 0,
        tm_hour: 0,
        tm_mday: 0,
        tm_mon: 0,
        tm_year: 0,
        tm_wday: 0,
        tm_yday: 0,
        tm_isdst: 0,
        tm_gmtoff: 0,
        tm_zone: std::ptr::null::<libc::c_char>(),
    };
    let mut now: time_t = 0;
    let mut age: time_t = 0;
    let mut s: [libc::c_char; 9] = [0; 9];
    time(&mut now);
    if now < t {
        now = t;
    }
    age = now - t;
    localtime_r(&mut now, &mut now_tm);
    localtime_r(&mut t, &mut tm);
    if age < (24 as libc::c_int * 3600 as libc::c_int) as libc::c_long {
        if seconds != 0 {
            strftime(
                s.as_mut_ptr(),
                ::core::mem::size_of::<[libc::c_char; 9]>() as libc::c_ulong,
                b"%H:%M:%S\0" as *const u8 as *const libc::c_char,
                &mut tm,
            );
        } else {
            strftime(
                s.as_mut_ptr(),
                ::core::mem::size_of::<[libc::c_char; 9]>() as libc::c_ulong,
                b"%H:%M\0" as *const u8 as *const libc::c_char,
                &mut tm,
            );
        }
        return xstrdup(s.as_mut_ptr());
    }
    if tm.tm_year == now_tm.tm_year && tm.tm_mon == now_tm.tm_mon
        || age < (28 as libc::c_int * 24 as libc::c_int * 3600 as libc::c_int) as libc::c_long
    {
        strftime(
            s.as_mut_ptr(),
            ::core::mem::size_of::<[libc::c_char; 9]>() as libc::c_ulong,
            b"%a%d\0" as *const u8 as *const libc::c_char,
            &mut tm,
        );
        return xstrdup(s.as_mut_ptr());
    }
    if tm.tm_year == now_tm.tm_year && tm.tm_mon < now_tm.tm_mon
        || tm.tm_year == now_tm.tm_year - 1 as libc::c_int && tm.tm_mon > now_tm.tm_mon
    {
        strftime(
            s.as_mut_ptr(),
            ::core::mem::size_of::<[libc::c_char; 9]>() as libc::c_ulong,
            b"%d%b\0" as *const u8 as *const libc::c_char,
            &mut tm,
        );
        return xstrdup(s.as_mut_ptr());
    }
    strftime(
        s.as_mut_ptr(),
        ::core::mem::size_of::<[libc::c_char; 9]>() as libc::c_ulong,
        b"%h%y\0" as *const u8 as *const libc::c_char,
        &mut tm,
    );
    return xstrdup(s.as_mut_ptr());
}
unsafe extern "C" fn format_find(
    mut ft: *mut format_tree,
    mut key: *const libc::c_char,
    mut modifiers: libc::c_int,
    mut time_format: *const libc::c_char,
) -> *mut libc::c_char {
    let mut current_block: u64;
    let mut fte: *mut format_table_entry = std::ptr::null_mut::<format_table_entry>();
    let mut value: *mut libc::c_void = std::ptr::null_mut::<libc::c_void>();
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_find: format_entry = format_entry {
        key: std::ptr::null_mut::<libc::c_char>(),
        value: std::ptr::null_mut::<libc::c_char>(),
        time: 0,
        cb: None,
        entry: C2RustUnnamed_27 {
            rbe_left: std::ptr::null_mut::<format_entry>(),
            rbe_right: std::ptr::null_mut::<format_entry>(),
            rbe_parent: std::ptr::null_mut::<format_entry>(),
            rbe_color: 0,
        },
    };
    let mut envent: *mut environ_entry = std::ptr::null_mut::<environ_entry>();
    let mut o: *mut options_entry = std::ptr::null_mut::<options_entry>();
    let mut idx: libc::c_int = 0;
    let mut found: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut saved: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut s: [libc::c_char; 512] = [0; 512];
    let mut errstr: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut t: time_t = 0 as libc::c_int as time_t;
    let mut tm: tm = tm {
        tm_sec: 0,
        tm_min: 0,
        tm_hour: 0,
        tm_mday: 0,
        tm_mon: 0,
        tm_year: 0,
        tm_wday: 0,
        tm_yday: 0,
        tm_isdst: 0,
        tm_gmtoff: 0,
        tm_zone: std::ptr::null::<libc::c_char>(),
    };
    o = options_parse_get(global_options, key, &mut idx, 0 as libc::c_int);
    if o.is_null() && !((*ft).wp).is_null() {
        o = options_parse_get((*(*ft).wp).options, key, &mut idx, 0 as libc::c_int);
    }
    if o.is_null() && !((*ft).w).is_null() {
        o = options_parse_get((*(*ft).w).options, key, &mut idx, 0 as libc::c_int);
    }
    if o.is_null() {
        o = options_parse_get(global_w_options, key, &mut idx, 0 as libc::c_int);
    }
    if o.is_null() && !((*ft).s).is_null() {
        o = options_parse_get((*(*ft).s).options, key, &mut idx, 0 as libc::c_int);
    }
    if o.is_null() {
        o = options_parse_get(global_s_options, key, &mut idx, 0 as libc::c_int);
    }
    if !o.is_null() {
        found = options_to_string(o, idx, 1 as libc::c_int);
    } else {
        fte = format_table_get(key);
        if !fte.is_null() {
            value = ((*fte).cb).expect("non-null function pointer")(ft);
            if (*fte).type_0 as libc::c_uint == FORMAT_TABLE_TIME as libc::c_int as libc::c_uint
                && !value.is_null()
            {
                t = (*(value as *mut timeval)).tv_sec;
            } else {
                found = value as *mut libc::c_char;
            }
        } else {
            fe_find.key = key as *mut libc::c_char;
            fe = format_entry_tree_RB_FIND(&mut (*ft).tree, &mut fe_find);
            if !fe.is_null() {
                if (*fe).time != 0 as libc::c_int as libc::c_long {
                    t = (*fe).time;
                } else {
                    if ((*fe).value).is_null() && ((*fe).cb).is_some() {
                        (*fe).value =
                            ((*fe).cb).expect("non-null function pointer")(ft) as *mut libc::c_char;
                        if ((*fe).value).is_null() {
                            (*fe).value = xstrdup(b"\0" as *const u8 as *const libc::c_char);
                        }
                    }
                    found = xstrdup((*fe).value);
                }
            } else {
                if !modifiers & 0x1 as libc::c_int != 0 {
                    envent = std::ptr::null_mut::<environ_entry>();
                    if !((*ft).s).is_null() {
                        envent = environ_find((*(*ft).s).environ, key);
                    }
                    if envent.is_null() {
                        envent = environ_find(global_environ, key);
                    }
                    if !envent.is_null() && !((*envent).value).is_null() {
                        found = xstrdup((*envent).value);
                        current_block = 13074811197591252876;
                    } else {
                        current_block = 17184638872671510253;
                    }
                } else {
                    current_block = 17184638872671510253;
                }
                match current_block {
                    13074811197591252876 => {}
                    _ => return std::ptr::null_mut::<libc::c_char>(),
                }
            }
        }
    }
    if modifiers & 0x1 as libc::c_int != 0 {
        if t == 0 as libc::c_int as libc::c_long && !found.is_null() {
            t = strtonum(
                found,
                0 as libc::c_int as libc::c_longlong,
                9223372036854775807 as libc::c_long as libc::c_longlong,
                &mut errstr,
            ) as time_t;
            if !errstr.is_null() {
                t = 0 as libc::c_int as time_t;
            }
            free(found as *mut libc::c_void);
        }
        if t == 0 as libc::c_int as libc::c_long {
            return std::ptr::null_mut::<libc::c_char>();
        }
        if modifiers & 0x400 as libc::c_int != 0 {
            found = format_pretty_time(t, 0 as libc::c_int);
        } else {
            if !time_format.is_null() {
                localtime_r(&mut t, &mut tm);
                strftime(
                    s.as_mut_ptr(),
                    ::core::mem::size_of::<[libc::c_char; 512]>() as libc::c_ulong,
                    time_format,
                    &mut tm,
                );
            } else {
                ctime_r(&mut t, s.as_mut_ptr());
                s[strcspn(s.as_mut_ptr(), b"\n\0" as *const u8 as *const libc::c_char) as usize] =
                    '\0' as i32 as libc::c_char;
            }
            found = xstrdup(s.as_mut_ptr());
        }
        return found;
    }
    if t != 0 as libc::c_int as libc::c_long {
        xasprintf(
            &mut found as *mut *mut libc::c_char,
            b"%lld\0" as *const u8 as *const libc::c_char,
            t as libc::c_longlong,
        );
    } else if found.is_null() {
        return std::ptr::null_mut::<libc::c_char>();
    }
    if modifiers & 0x2 as libc::c_int != 0 {
        saved = found;
        found = xstrdup(__xpg_basename(saved));
        free(saved as *mut libc::c_void);
    }
    if modifiers & 0x4 as libc::c_int != 0 {
        saved = found;
        found = xstrdup(dirname(saved));
        free(saved as *mut libc::c_void);
    }
    if modifiers & 0x8 as libc::c_int != 0 {
        saved = found;
        found = format_quote_shell(saved);
        free(saved as *mut libc::c_void);
    }
    if modifiers & 0x2000 as libc::c_int != 0 {
        saved = found;
        found = format_quote_style(saved);
        free(saved as *mut libc::c_void);
    }
    return found;
}
unsafe extern "C" fn format_unescape(mut s: *const libc::c_char) -> *mut libc::c_char {
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut cp: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut brackets: libc::c_int = 0 as libc::c_int;
    out = xmalloc((strlen(s)).wrapping_add(1 as libc::c_int as libc::c_ulong)) as *mut libc::c_char;
    cp = out;
    while *s as libc::c_int != '\0' as i32 {
        if *s as libc::c_int == '#' as i32
            && *s.offset(1 as libc::c_int as isize) as libc::c_int == '{' as i32
        {
            brackets += 1;
        }
        if brackets == 0 as libc::c_int
            && *s as libc::c_int == '#' as i32
            && !(strchr(
                b",#{}:\0" as *const u8 as *const libc::c_char,
                *s.offset(1 as libc::c_int as isize) as libc::c_int,
            ))
            .is_null()
        {
            s = s.offset(1);
            let fresh4 = cp;
            cp = cp.offset(1);
            *fresh4 = *s;
        } else {
            if *s as libc::c_int == '}' as i32 {
                brackets -= 1;
            }
            let fresh5 = cp;
            cp = cp.offset(1);
            *fresh5 = *s;
        }
        s = s.offset(1);
    }
    *cp = '\0' as i32 as libc::c_char;
    return out;
}
unsafe extern "C" fn format_strip(mut s: *const libc::c_char) -> *mut libc::c_char {
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut cp: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut brackets: libc::c_int = 0 as libc::c_int;
    out = xmalloc((strlen(s)).wrapping_add(1 as libc::c_int as libc::c_ulong)) as *mut libc::c_char;
    cp = out;
    while *s as libc::c_int != '\0' as i32 {
        if *s as libc::c_int == '#' as i32
            && *s.offset(1 as libc::c_int as isize) as libc::c_int == '{' as i32
        {
            brackets += 1;
        }
        if *s as libc::c_int == '#' as i32
            && !(strchr(
                b",#{}:\0" as *const u8 as *const libc::c_char,
                *s.offset(1 as libc::c_int as isize) as libc::c_int,
            ))
            .is_null()
        {
            if brackets != 0 as libc::c_int {
                let fresh6 = cp;
                cp = cp.offset(1);
                *fresh6 = *s;
            }
        } else {
            if *s as libc::c_int == '}' as i32 {
                brackets -= 1;
            }
            let fresh7 = cp;
            cp = cp.offset(1);
            *fresh7 = *s;
        }
        s = s.offset(1);
    }
    *cp = '\0' as i32 as libc::c_char;
    return out;
}
#[no_mangle]
pub unsafe extern "C" fn format_skip(
    mut s: *const libc::c_char,
    mut end: *const libc::c_char,
) -> *const libc::c_char {
    let mut brackets: libc::c_int = 0 as libc::c_int;
    while *s as libc::c_int != '\0' as i32 {
        if *s as libc::c_int == '#' as i32
            && *s.offset(1 as libc::c_int as isize) as libc::c_int == '{' as i32
        {
            brackets += 1;
        }
        if *s as libc::c_int == '#' as i32
            && *s.offset(1 as libc::c_int as isize) as libc::c_int != '\0' as i32
            && !(strchr(
                b",#{}:\0" as *const u8 as *const libc::c_char,
                *s.offset(1 as libc::c_int as isize) as libc::c_int,
            ))
            .is_null()
        {
            s = s.offset(1);
        } else {
            if *s as libc::c_int == '}' as i32 {
                brackets -= 1;
            }
            if !(strchr(end, *s as libc::c_int)).is_null() && brackets == 0 as libc::c_int {
                break;
            }
        }
        s = s.offset(1);
    }
    if *s as libc::c_int == '\0' as i32 {
        return std::ptr::null::<libc::c_char>();
    }
    return s;
}
unsafe extern "C" fn format_choose(
    mut es: *mut format_expand_state,
    mut s: *const libc::c_char,
    mut left: *mut *mut libc::c_char,
    mut right: *mut *mut libc::c_char,
    mut expand: libc::c_int,
) -> libc::c_int {
    let mut cp: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut left0: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut right0: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    cp = format_skip(s, b",\0" as *const u8 as *const libc::c_char);
    if cp.is_null() {
        return -(1 as libc::c_int);
    }
    left0 = xstrndup(s, cp.offset_from(s) as libc::c_long as size_t);
    right0 = xstrdup(cp.offset(1 as libc::c_int as isize));
    if expand != 0 {
        *left = format_expand1(es, left0);
        free(left0 as *mut libc::c_void);
        *right = format_expand1(es, right0);
        free(right0 as *mut libc::c_void);
    } else {
        *left = left0;
        *right = right0;
    }
    return 0 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn format_true(mut s: *const libc::c_char) -> libc::c_int {
    if !s.is_null()
        && *s as libc::c_int != '\0' as i32
        && (*s.offset(0 as libc::c_int as isize) as libc::c_int != '0' as i32
            || *s.offset(1 as libc::c_int as isize) as libc::c_int != '\0' as i32)
    {
        return 1 as libc::c_int;
    }
    return 0 as libc::c_int;
}
unsafe extern "C" fn format_is_end(mut c: libc::c_char) -> libc::c_int {
    return (c as libc::c_int == ';' as i32 || c as libc::c_int == ':' as i32) as libc::c_int;
}
unsafe extern "C" fn format_add_modifier(
    mut list: *mut *mut format_modifier,
    mut count: *mut u_int,
    mut c: *const libc::c_char,
    mut n: size_t,
    mut argv: *mut *mut libc::c_char,
    mut argc: libc::c_int,
) {
    let mut fm: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    *list = xreallocarray(
        *list as *mut libc::c_void,
        (*count).wrapping_add(1 as libc::c_int as libc::c_uint) as size_t,
        ::core::mem::size_of::<format_modifier>() as libc::c_ulong,
    ) as *mut format_modifier;
    let fresh8 = *count;
    *count = (*count).wrapping_add(1);
    fm = &mut *(*list).offset(fresh8 as isize) as *mut format_modifier;
    memcpy(
        ((*fm).modifier).as_mut_ptr() as *mut libc::c_void,
        c as *const libc::c_void,
        n,
    );
    (*fm).modifier[n as usize] = '\0' as i32 as libc::c_char;
    (*fm).size = n as u_int;
    (*fm).argv = argv;
    (*fm).argc = argc;
}
unsafe extern "C" fn format_free_modifiers(mut list: *mut format_modifier, mut count: u_int) {
    let mut i: u_int = 0;
    i = 0 as libc::c_int as u_int;
    while i < count {
        cmd_free_argv(
            (*list.offset(i as isize)).argc,
            (*list.offset(i as isize)).argv,
        );
        i = i.wrapping_add(1);
    }
    free(list as *mut libc::c_void);
}
unsafe extern "C" fn format_build_modifiers(
    mut es: *mut format_expand_state,
    mut s: *mut *const libc::c_char,
    mut count: *mut u_int,
) -> *mut format_modifier {
    let mut cp: *const libc::c_char = *s;
    let mut end: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut list: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut c: libc::c_char = 0;
    let mut last: [libc::c_char; 4] =
        *::core::mem::transmute::<&[u8; 4], &mut [libc::c_char; 4]>(b"X;:\0");
    let mut argv: *mut *mut libc::c_char = std::ptr::null_mut::<*mut libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut argc: libc::c_int = 0;
    *count = 0 as libc::c_int as u_int;
    while *cp as libc::c_int != '\0' as i32 && *cp as libc::c_int != ':' as i32 {
        if *cp as libc::c_int == ';' as i32 {
            cp = cp.offset(1);
        }
        if !(strchr(
            b"labcdnwETSWPL<>\0" as *const u8 as *const libc::c_char,
            *cp.offset(0 as libc::c_int as isize) as libc::c_int,
        ))
        .is_null()
            && format_is_end(*cp.offset(1 as libc::c_int as isize)) != 0
        {
            format_add_modifier(
                &mut list,
                count,
                cp,
                1 as libc::c_int as size_t,
                std::ptr::null_mut::<*mut libc::c_char>(),
                0 as libc::c_int,
            );
            cp = cp.offset(1);
        } else if (memcmp(
            b"||\0" as *const u8 as *const libc::c_char as *const libc::c_void,
            cp as *const libc::c_void,
            2 as libc::c_int as libc::c_ulong,
        ) == 0 as libc::c_int
            || memcmp(
                b"&&\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                cp as *const libc::c_void,
                2 as libc::c_int as libc::c_ulong,
            ) == 0 as libc::c_int
            || memcmp(
                b"!=\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                cp as *const libc::c_void,
                2 as libc::c_int as libc::c_ulong,
            ) == 0 as libc::c_int
            || memcmp(
                b"==\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                cp as *const libc::c_void,
                2 as libc::c_int as libc::c_ulong,
            ) == 0 as libc::c_int
            || memcmp(
                b"<=\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                cp as *const libc::c_void,
                2 as libc::c_int as libc::c_ulong,
            ) == 0 as libc::c_int
            || memcmp(
                b">=\0" as *const u8 as *const libc::c_char as *const libc::c_void,
                cp as *const libc::c_void,
                2 as libc::c_int as libc::c_ulong,
            ) == 0 as libc::c_int)
            && format_is_end(*cp.offset(2 as libc::c_int as isize)) != 0
        {
            format_add_modifier(
                &mut list,
                count,
                cp,
                2 as libc::c_int as size_t,
                std::ptr::null_mut::<*mut libc::c_char>(),
                0 as libc::c_int,
            );
            cp = cp.offset(2 as libc::c_int as isize);
        } else {
            if (strchr(
                b"mCNst=peq\0" as *const u8 as *const libc::c_char,
                *cp.offset(0 as libc::c_int as isize) as libc::c_int,
            ))
            .is_null()
            {
                break;
            }
            c = *cp.offset(0 as libc::c_int as isize);
            if format_is_end(*cp.offset(1 as libc::c_int as isize)) != 0 {
                format_add_modifier(
                    &mut list,
                    count,
                    cp,
                    1 as libc::c_int as size_t,
                    std::ptr::null_mut::<*mut libc::c_char>(),
                    0 as libc::c_int,
                );
                cp = cp.offset(1);
            } else {
                argv = std::ptr::null_mut::<*mut libc::c_char>();
                argc = 0 as libc::c_int;
                if *(*__ctype_b_loc())
                    .offset(*cp.offset(1 as libc::c_int as isize) as u_char as libc::c_int as isize)
                    as libc::c_int
                    & _ISpunct as libc::c_int as libc::c_ushort as libc::c_int
                    == 0
                    || *cp.offset(1 as libc::c_int as isize) as libc::c_int == '-' as i32
                {
                    end = format_skip(
                        cp.offset(1 as libc::c_int as isize),
                        b":;\0" as *const u8 as *const libc::c_char,
                    );
                    if end.is_null() {
                        break;
                    }
                    argv = xcalloc(
                        1 as libc::c_int as size_t,
                        ::core::mem::size_of::<*mut libc::c_char>() as libc::c_ulong,
                    ) as *mut *mut libc::c_char;
                    value = xstrndup(
                        cp.offset(1 as libc::c_int as isize),
                        end.offset_from(cp.offset(1 as libc::c_int as isize)) as libc::c_long
                            as size_t,
                    );
                    let fresh9 = &mut (*argv.offset(0 as libc::c_int as isize));
                    *fresh9 = format_expand1(es, value);
                    free(value as *mut libc::c_void);
                    argc = 1 as libc::c_int;
                    format_add_modifier(
                        &mut list,
                        count,
                        &mut c,
                        1 as libc::c_int as size_t,
                        argv,
                        argc,
                    );
                    cp = end;
                } else {
                    last[0 as libc::c_int as usize] = *cp.offset(1 as libc::c_int as isize);
                    cp = cp.offset(1);
                    loop {
                        if *cp.offset(0 as libc::c_int as isize) as libc::c_int
                            == last[0 as libc::c_int as usize] as libc::c_int
                            && format_is_end(*cp.offset(1 as libc::c_int as isize)) != 0
                        {
                            cp = cp.offset(1);
                            break;
                        } else {
                            end = format_skip(
                                cp.offset(1 as libc::c_int as isize),
                                last.as_mut_ptr(),
                            );
                            if end.is_null() {
                                break;
                            }
                            cp = cp.offset(1);
                            argv = xreallocarray(
                                argv as *mut libc::c_void,
                                (argc + 1 as libc::c_int) as size_t,
                                ::core::mem::size_of::<*mut libc::c_char>() as libc::c_ulong,
                            ) as *mut *mut libc::c_char;
                            value = xstrndup(cp, end.offset_from(cp) as libc::c_long as size_t);
                            let fresh10 = argc;
                            argc = argc + 1;
                            let fresh11 = &mut (*argv.offset(fresh10 as isize));
                            *fresh11 = format_expand1(es, value);
                            free(value as *mut libc::c_void);
                            cp = end;
                            if format_is_end(*cp.offset(0 as libc::c_int as isize)) != 0 {
                                break;
                            }
                        }
                    }
                    format_add_modifier(
                        &mut list,
                        count,
                        &mut c,
                        1 as libc::c_int as size_t,
                        argv,
                        argc,
                    );
                }
            }
        }
    }
    if *cp as libc::c_int != ':' as i32 {
        format_free_modifiers(list, *count);
        *count = 0 as libc::c_int as u_int;
        return std::ptr::null_mut::<format_modifier>();
    }
    *s = cp.offset(1 as libc::c_int as isize);
    return list;
}
unsafe extern "C" fn format_match(
    mut fm: *mut format_modifier,
    mut pattern: *const libc::c_char,
    mut text: *const libc::c_char,
) -> *mut libc::c_char {
    let mut s: *const libc::c_char = b"\0" as *const u8 as *const libc::c_char;
    let mut r: regex_t = regex_t {
        buffer: std::ptr::null_mut::<re_dfa_t>(),
        allocated: 0,
        used: 0,
        syntax: 0,
        fastmap: std::ptr::null_mut::<libc::c_char>(),
        translate: std::ptr::null_mut::<libc::c_uchar>(),
        re_nsub: 0,
        can_be_null_regs_allocated_fastmap_accurate_no_sub_not_bol_not_eol_newline_anchor: [0; 1],
        c2rust_padding: [0; 7],
    };
    let mut flags: libc::c_int = 0 as libc::c_int;
    if (*fm).argc >= 1 as libc::c_int {
        s = *((*fm).argv).offset(0 as libc::c_int as isize);
    }
    if (strchr(s, 'r' as i32)).is_null() {
        if !(strchr(s, 'i' as i32)).is_null() {
            flags |= (1 as libc::c_int) << 4 as libc::c_int;
        }
        if fnmatch(pattern, text, flags) != 0 as libc::c_int {
            return xstrdup(b"0\0" as *const u8 as *const libc::c_char);
        }
    } else {
        flags = 1 as libc::c_int | (1 as libc::c_int) << 3 as libc::c_int;
        if !(strchr(s, 'i' as i32)).is_null() {
            flags |= (1 as libc::c_int) << 1 as libc::c_int;
        }
        if regcomp(&mut r, pattern, flags) != 0 as libc::c_int {
            return xstrdup(b"0\0" as *const u8 as *const libc::c_char);
        }
        if regexec(
            &mut r,
            text,
            0 as libc::c_int as size_t,
            std::ptr::null_mut::<regmatch_t>(),
            0 as libc::c_int,
        ) != 0 as libc::c_int
        {
            regfree(&mut r);
            return xstrdup(b"0\0" as *const u8 as *const libc::c_char);
        }
        regfree(&mut r);
    }
    return xstrdup(b"1\0" as *const u8 as *const libc::c_char);
}
unsafe extern "C" fn format_sub(
    mut fm: *mut format_modifier,
    mut text: *const libc::c_char,
    mut pattern: *const libc::c_char,
    mut with: *const libc::c_char,
) -> *mut libc::c_char {
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut flags: libc::c_int = 1 as libc::c_int;
    if (*fm).argc >= 3 as libc::c_int
        && !(strchr(*((*fm).argv).offset(2 as libc::c_int as isize), 'i' as i32)).is_null()
    {
        flags |= (1 as libc::c_int) << 1 as libc::c_int;
    }
    value = regsub(pattern, with, text, flags);
    if value.is_null() {
        return xstrdup(text);
    }
    return value;
}
unsafe extern "C" fn format_search(
    mut fm: *mut format_modifier,
    mut wp: *mut window_pane,
    mut s: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ignore: libc::c_int = 0 as libc::c_int;
    let mut regex: libc::c_int = 0 as libc::c_int;
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    if (*fm).argc >= 1 as libc::c_int {
        if !(strchr(*((*fm).argv).offset(0 as libc::c_int as isize), 'i' as i32)).is_null() {
            ignore = 1 as libc::c_int;
        }
        if !(strchr(*((*fm).argv).offset(0 as libc::c_int as isize), 'r' as i32)).is_null() {
            regex = 1 as libc::c_int;
        }
    }
    xasprintf(
        &mut value as *mut *mut libc::c_char,
        b"%u\0" as *const u8 as *const libc::c_char,
        window_pane_search(wp, s, regex, ignore),
    );
    return value;
}
unsafe extern "C" fn format_session_name(
    mut es: *mut format_expand_state,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut name: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut s: *mut session = std::ptr::null_mut::<session>();
    name = format_expand1(es, fmt);
    s = sessions_RB_MINMAX(&mut sessions, -(1 as libc::c_int));
    while !s.is_null() {
        if strcmp((*s).name, name) == 0 as libc::c_int {
            free(name as *mut libc::c_void);
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char);
        }
        s = sessions_RB_NEXT(s);
    }
    free(name as *mut libc::c_void);
    return xstrdup(b"0\0" as *const u8 as *const libc::c_char);
}
unsafe extern "C" fn format_loop_sessions(
    mut es: *mut format_expand_state,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = (*es).ft;
    let mut c: *mut client = (*ft).client;
    let mut item: *mut cmdq_item = (*ft).item;
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    let mut expanded: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut valuelen: size_t = 0;
    let mut s: *mut session = std::ptr::null_mut::<session>();
    value = xcalloc(1 as libc::c_int as size_t, 1 as libc::c_int as size_t) as *mut libc::c_char;
    valuelen = 1 as libc::c_int as size_t;
    s = sessions_RB_MINMAX(&mut sessions, -(1 as libc::c_int));
    while !s.is_null() {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 21], &[libc::c_char; 21]>(b"format_loop_sessions\0"))
                .as_ptr(),
            b"session loop: $%u\0" as *const u8 as *const libc::c_char,
            (*s).id,
        );
        nft = format_create(c, item, 0 as libc::c_int, (*ft).flags);
        format_defaults(
            nft,
            (*ft).c,
            s,
            std::ptr::null_mut::<winlink>(),
            std::ptr::null_mut::<window_pane>(),
        );
        format_copy_state(&mut next, es, 0 as libc::c_int);
        next.ft = nft;
        expanded = format_expand1(&mut next, fmt);
        format_free(next.ft);
        valuelen = (valuelen as libc::c_ulong).wrapping_add(strlen(expanded)) as size_t as size_t;
        value = xrealloc(value as *mut libc::c_void, valuelen) as *mut libc::c_char;
        strlcat(value, expanded, valuelen);
        free(expanded as *mut libc::c_void);
        s = sessions_RB_NEXT(s);
    }
    return value;
}
unsafe extern "C" fn format_window_name(
    mut es: *mut format_expand_state,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = (*es).ft;
    let mut name: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    if ((*ft).s).is_null() {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 19], &[libc::c_char; 19]>(b"format_window_name\0"))
                .as_ptr(),
            b"window name but no session\0" as *const u8 as *const libc::c_char,
        );
        return std::ptr::null_mut::<libc::c_char>();
    }
    name = format_expand1(es, fmt);
    wl = winlinks_RB_MINMAX(&mut (*(*ft).s).windows, -(1 as libc::c_int));
    while !wl.is_null() {
        if strcmp((*(*wl).window).name, name) == 0 as libc::c_int {
            free(name as *mut libc::c_void);
            return xstrdup(b"1\0" as *const u8 as *const libc::c_char);
        }
        wl = winlinks_RB_NEXT(wl);
    }
    free(name as *mut libc::c_void);
    return xstrdup(b"0\0" as *const u8 as *const libc::c_char);
}
unsafe extern "C" fn format_loop_windows(
    mut es: *mut format_expand_state,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = (*es).ft;
    let mut c: *mut client = (*ft).client;
    let mut item: *mut cmdq_item = (*ft).item;
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    let mut all: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut active: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut use_0: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut expanded: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut valuelen: size_t = 0;
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut w: *mut window = std::ptr::null_mut::<window>();
    if ((*ft).s).is_null() {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 20], &[libc::c_char; 20]>(b"format_loop_windows\0"))
                .as_ptr(),
            b"window loop but no session\0" as *const u8 as *const libc::c_char,
        );
        return std::ptr::null_mut::<libc::c_char>();
    }
    if format_choose(es, fmt, &mut all, &mut active, 0 as libc::c_int) != 0 as libc::c_int {
        all = xstrdup(fmt);
        active = std::ptr::null_mut::<libc::c_char>();
    }
    value = xcalloc(1 as libc::c_int as size_t, 1 as libc::c_int as size_t) as *mut libc::c_char;
    valuelen = 1 as libc::c_int as size_t;
    wl = winlinks_RB_MINMAX(&mut (*(*ft).s).windows, -(1 as libc::c_int));
    while !wl.is_null() {
        w = (*wl).window;
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 20], &[libc::c_char; 20]>(b"format_loop_windows\0"))
                .as_ptr(),
            b"window loop: %u @%u\0" as *const u8 as *const libc::c_char,
            (*wl).idx,
            (*w).id,
        );
        if !active.is_null() && wl == (*(*ft).s).curw {
            use_0 = active;
        } else {
            use_0 = all;
        }
        nft = format_create(
            c,
            item,
            (0x40000000 as libc::c_uint | (*w).id) as libc::c_int,
            (*ft).flags,
        );
        format_defaults(
            nft,
            (*ft).c,
            (*ft).s,
            wl,
            std::ptr::null_mut::<window_pane>(),
        );
        format_copy_state(&mut next, es, 0 as libc::c_int);
        next.ft = nft;
        expanded = format_expand1(&mut next, use_0);
        format_free(nft);
        valuelen = (valuelen as libc::c_ulong).wrapping_add(strlen(expanded)) as size_t as size_t;
        value = xrealloc(value as *mut libc::c_void, valuelen) as *mut libc::c_char;
        strlcat(value, expanded, valuelen);
        free(expanded as *mut libc::c_void);
        wl = winlinks_RB_NEXT(wl);
    }
    free(active as *mut libc::c_void);
    free(all as *mut libc::c_void);
    return value;
}
unsafe extern "C" fn format_loop_panes(
    mut es: *mut format_expand_state,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = (*es).ft;
    let mut c: *mut client = (*ft).client;
    let mut item: *mut cmdq_item = (*ft).item;
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    let mut all: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut active: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut use_0: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut expanded: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut valuelen: size_t = 0;
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    if ((*ft).w).is_null() {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"format_loop_panes\0"))
                .as_ptr(),
            b"pane loop but no window\0" as *const u8 as *const libc::c_char,
        );
        return std::ptr::null_mut::<libc::c_char>();
    }
    if format_choose(es, fmt, &mut all, &mut active, 0 as libc::c_int) != 0 as libc::c_int {
        all = xstrdup(fmt);
        active = std::ptr::null_mut::<libc::c_char>();
    }
    value = xcalloc(1 as libc::c_int as size_t, 1 as libc::c_int as size_t) as *mut libc::c_char;
    valuelen = 1 as libc::c_int as size_t;
    wp = (*(*ft).w).panes.tqh_first;
    while !wp.is_null() {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 18], &[libc::c_char; 18]>(b"format_loop_panes\0"))
                .as_ptr(),
            b"pane loop: %%%u\0" as *const u8 as *const libc::c_char,
            (*wp).id,
        );
        if !active.is_null() && wp == (*(*ft).w).active {
            use_0 = active;
        } else {
            use_0 = all;
        }
        nft = format_create(
            c,
            item,
            (0x80000000 as libc::c_uint | (*wp).id) as libc::c_int,
            (*ft).flags,
        );
        format_defaults(nft, (*ft).c, (*ft).s, (*ft).wl, wp);
        format_copy_state(&mut next, es, 0 as libc::c_int);
        next.ft = nft;
        expanded = format_expand1(&mut next, use_0);
        format_free(nft);
        valuelen = (valuelen as libc::c_ulong).wrapping_add(strlen(expanded)) as size_t as size_t;
        value = xrealloc(value as *mut libc::c_void, valuelen) as *mut libc::c_char;
        strlcat(value, expanded, valuelen);
        free(expanded as *mut libc::c_void);
        wp = (*wp).entry.tqe_next;
    }
    free(active as *mut libc::c_void);
    free(all as *mut libc::c_void);
    return value;
}
unsafe extern "C" fn format_loop_clients(
    mut es: *mut format_expand_state,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = (*es).ft;
    let mut c: *mut client = std::ptr::null_mut::<client>();
    let mut item: *mut cmdq_item = (*ft).item;
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    let mut expanded: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut valuelen: size_t = 0;
    value = xcalloc(1 as libc::c_int as size_t, 1 as libc::c_int as size_t) as *mut libc::c_char;
    valuelen = 1 as libc::c_int as size_t;
    c = clients.tqh_first;
    while !c.is_null() {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 20], &[libc::c_char; 20]>(b"format_loop_clients\0"))
                .as_ptr(),
            b"client loop: %s\0" as *const u8 as *const libc::c_char,
            (*c).name,
        );
        nft = format_create(c, item, 0 as libc::c_int, (*ft).flags);
        format_defaults(nft, c, (*ft).s, (*ft).wl, (*ft).wp);
        format_copy_state(&mut next, es, 0 as libc::c_int);
        next.ft = nft;
        expanded = format_expand1(&mut next, fmt);
        format_free(nft);
        valuelen = (valuelen as libc::c_ulong).wrapping_add(strlen(expanded)) as size_t as size_t;
        value = xrealloc(value as *mut libc::c_void, valuelen) as *mut libc::c_char;
        strlcat(value, expanded, valuelen);
        free(expanded as *mut libc::c_void);
        c = (*c).entry.tqe_next;
    }
    return value;
}
unsafe extern "C" fn format_replace_expression(
    mut mexp: *mut format_modifier,
    mut es: *mut format_expand_state,
    mut copy: *const libc::c_char,
) -> *mut libc::c_char {
    let mut current_block: u64;
    let mut argc: libc::c_int = (*mexp).argc;
    let mut errstr: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut endch: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut left: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut right: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut use_fp: libc::c_int = 0 as libc::c_int;
    let mut prec: u_int = 0 as libc::c_int as u_int;
    let mut mleft: libc::c_double = 0.;
    let mut mright: libc::c_double = 0.;
    let mut result: libc::c_double = 0.;
    let mut operator: C2RustUnnamed_40 = ADD;
    if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"+\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = ADD;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"-\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = SUBTRACT;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"*\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = MULTIPLY;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"/\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = DIVIDE;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"%\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
        || strcmp(
            *((*mexp).argv).offset(0 as libc::c_int as isize),
            b"m\0" as *const u8 as *const libc::c_char,
        ) == 0 as libc::c_int
    {
        operator = MODULUS;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"==\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = EQUAL;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"!=\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = NOT_EQUAL;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b">\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = GREATER_THAN;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"<\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = LESS_THAN;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b">=\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = GREATER_THAN_EQUAL;
        current_block = 4495394744059808450;
    } else if strcmp(
        *((*mexp).argv).offset(0 as libc::c_int as isize),
        b"<=\0" as *const u8 as *const libc::c_char,
    ) == 0 as libc::c_int
    {
        operator = LESS_THAN_EQUAL;
        current_block = 4495394744059808450;
    } else {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                b"format_replace_expression\0",
            ))
            .as_ptr(),
            b"expression has no valid operator: '%s'\0" as *const u8 as *const libc::c_char,
            *((*mexp).argv).offset(0 as libc::c_int as isize),
        );
        current_block = 2341159035123514568;
    }
    match current_block {
        4495394744059808450 => {
            if argc >= 2 as libc::c_int
                && !(strchr(
                    *((*mexp).argv).offset(1 as libc::c_int as isize),
                    'f' as i32,
                ))
                .is_null()
            {
                use_fp = 1 as libc::c_int;
                prec = 2 as libc::c_int as u_int;
            }
            if argc >= 3 as libc::c_int {
                prec = strtonum(
                    *((*mexp).argv).offset(2 as libc::c_int as isize),
                    (-(2147483647 as libc::c_int) - 1 as libc::c_int) as libc::c_longlong,
                    2147483647 as libc::c_int as libc::c_longlong,
                    &mut errstr,
                ) as u_int;
                if !errstr.is_null() {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                            b"format_replace_expression\0",
                        ))
                        .as_ptr(),
                        b"expression precision %s: %s\0" as *const u8 as *const libc::c_char,
                        errstr,
                        *((*mexp).argv).offset(2 as libc::c_int as isize),
                    );
                    current_block = 2341159035123514568;
                } else {
                    current_block = 3437258052017859086;
                }
            } else {
                current_block = 3437258052017859086;
            }
            match current_block {
                2341159035123514568 => {}
                _ => {
                    if format_choose(es, copy, &mut left, &mut right, 1 as libc::c_int)
                        != 0 as libc::c_int
                    {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                                b"format_replace_expression\0",
                            ))
                            .as_ptr(),
                            b"expression syntax error\0" as *const u8 as *const libc::c_char,
                        );
                    } else {
                        mleft = strtod(left, &mut endch);
                        if *endch as libc::c_int != '\0' as i32 {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                                    b"format_replace_expression\0",
                                ))
                                .as_ptr(),
                                b"expression left side is invalid: %s\0" as *const u8
                                    as *const libc::c_char,
                                left,
                            );
                        } else {
                            mright = strtod(right, &mut endch);
                            if *endch as libc::c_int != '\0' as i32 {
                                format_log1(
                                    es,
                                    (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                                        b"format_replace_expression\0",
                                    ))
                                    .as_ptr(),
                                    b"expression right side is invalid: %s\0" as *const u8
                                        as *const libc::c_char,
                                    right,
                                );
                            } else {
                                if use_fp == 0 {
                                    mleft = mleft as libc::c_longlong as libc::c_double;
                                    mright = mright as libc::c_longlong as libc::c_double;
                                }
                                format_log1(
                                    es,
                                    (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                                        b"format_replace_expression\0",
                                    ))
                                    .as_ptr(),
                                    b"expression left side is: %.*f\0" as *const u8
                                        as *const libc::c_char,
                                    prec,
                                    mleft,
                                );
                                format_log1(
                                    es,
                                    (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                                        b"format_replace_expression\0",
                                    ))
                                    .as_ptr(),
                                    b"expression right side is: %.*f\0" as *const u8
                                        as *const libc::c_char,
                                    prec,
                                    mright,
                                );
                                match operator as libc::c_uint {
                                    0 => {
                                        result = mleft + mright;
                                    }
                                    1 => {
                                        result = mleft - mright;
                                    }
                                    2 => {
                                        result = mleft * mright;
                                    }
                                    3 => {
                                        result = mleft / mright;
                                    }
                                    4 => {
                                        result = fmod(mleft, mright);
                                    }
                                    5 => {
                                        result = (fabs(mleft - mright) < 1e-9f64) as libc::c_int
                                            as libc::c_double;
                                    }
                                    6 => {
                                        result = (fabs(mleft - mright) > 1e-9f64) as libc::c_int
                                            as libc::c_double;
                                    }
                                    7 => {
                                        result = (mleft > mright) as libc::c_int as libc::c_double;
                                    }
                                    8 => {
                                        result = (mleft >= mright) as libc::c_int as libc::c_double;
                                    }
                                    9 => {
                                        result = (mleft < mright) as libc::c_int as libc::c_double;
                                    }
                                    10 => {
                                        result = (mleft <= mright) as libc::c_int as libc::c_double;
                                    }
                                    _ => {}
                                }
                                if use_fp != 0 {
                                    xasprintf(
                                        &mut value as *mut *mut libc::c_char,
                                        b"%.*f\0" as *const u8 as *const libc::c_char,
                                        prec,
                                        result,
                                    );
                                } else {
                                    xasprintf(
                                        &mut value as *mut *mut libc::c_char,
                                        b"%.*f\0" as *const u8 as *const libc::c_char,
                                        prec,
                                        result as libc::c_longlong as libc::c_double,
                                    );
                                }
                                format_log1(
                                    es,
                                    (*::core::mem::transmute::<&[u8; 26], &[libc::c_char; 26]>(
                                        b"format_replace_expression\0",
                                    ))
                                    .as_ptr(),
                                    b"expression result is %s\0" as *const u8
                                        as *const libc::c_char,
                                    value,
                                );
                                free(right as *mut libc::c_void);
                                free(left as *mut libc::c_void);
                                return value;
                            }
                        }
                    }
                }
            }
        }
        _ => {}
    }
    free(right as *mut libc::c_void);
    free(left as *mut libc::c_void);
    return std::ptr::null_mut::<libc::c_char>();
}
unsafe extern "C" fn format_replace(
    mut es: *mut format_expand_state,
    mut key: *const libc::c_char,
    mut keylen: size_t,
    mut buf: *mut *mut libc::c_char,
    mut len: *mut size_t,
    mut off: *mut size_t,
) -> libc::c_int {
    let mut current_block: u64;
    let mut ft: *mut format_tree = (*es).ft;
    let mut wp: *mut window_pane = (*ft).wp;
    let mut errstr: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut copy: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut cp: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut marker: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut time_format: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut copy0: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut condition: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut found: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut new: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut value: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut left: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut right: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut valuelen: size_t = 0;
    let mut modifiers: libc::c_int = 0 as libc::c_int;
    let mut limit: libc::c_int = 0 as libc::c_int;
    let mut width: libc::c_int = 0 as libc::c_int;
    let mut j: libc::c_int = 0;
    let mut c: libc::c_int = 0;
    let mut list: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut cmp: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut search: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut sub: *mut *mut format_modifier = std::ptr::null_mut::<*mut format_modifier>();
    let mut mexp: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut fm: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut i: u_int = 0;
    let mut count: u_int = 0;
    let mut nsub: u_int = 0 as libc::c_int as u_int;
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    copy0 = xstrndup(key, keylen);
    copy = copy0;
    list = format_build_modifiers(es, &mut copy, &mut count);
    i = 0 as libc::c_int as u_int;
    while i < count {
        fm = &mut *list.offset(i as isize) as *mut format_modifier;
        if format_logging(ft) != 0 {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                    .as_ptr(),
                b"modifier %u is %s\0" as *const u8 as *const libc::c_char,
                i,
                ((*fm).modifier).as_mut_ptr(),
            );
            j = 0 as libc::c_int;
            while j < (*fm).argc {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"modifier %u argument %d: %s\0" as *const u8 as *const libc::c_char,
                    i,
                    j,
                    *((*fm).argv).offset(j as isize),
                );
                j += 1;
            }
        }
        if (*fm).size == 1 as libc::c_int as libc::c_uint {
            match (*fm).modifier[0 as libc::c_int as usize] as libc::c_int {
                109 | 60 | 62 => {
                    cmp = fm;
                }
                67 => {
                    search = fm;
                }
                115 => {
                    if (*fm).argc >= 2 as libc::c_int {
                        sub = xreallocarray(
                            sub as *mut libc::c_void,
                            nsub.wrapping_add(1 as libc::c_int as libc::c_uint) as size_t,
                            ::core::mem::size_of::<*mut format_modifier>() as libc::c_ulong,
                        ) as *mut *mut format_modifier;
                        let fresh12 = nsub;
                        nsub = nsub.wrapping_add(1);
                        let fresh13 = &mut (*sub.offset(fresh12 as isize));
                        *fresh13 = fm;
                    }
                }
                61 => {
                    if (*fm).argc >= 1 as libc::c_int {
                        limit = strtonum(
                            *((*fm).argv).offset(0 as libc::c_int as isize),
                            (-(2147483647 as libc::c_int) - 1 as libc::c_int) as libc::c_longlong,
                            2147483647 as libc::c_int as libc::c_longlong,
                            &mut errstr,
                        ) as libc::c_int;
                        if !errstr.is_null() {
                            limit = 0 as libc::c_int;
                        }
                        if (*fm).argc >= 2 as libc::c_int
                            && !(*((*fm).argv).offset(1 as libc::c_int as isize)).is_null()
                        {
                            marker = *((*fm).argv).offset(1 as libc::c_int as isize);
                        }
                    }
                }
                112 => {
                    if (*fm).argc >= 1 as libc::c_int {
                        width = strtonum(
                            *((*fm).argv).offset(0 as libc::c_int as isize),
                            (-(2147483647 as libc::c_int) - 1 as libc::c_int) as libc::c_longlong,
                            2147483647 as libc::c_int as libc::c_longlong,
                            &mut errstr,
                        ) as libc::c_int;
                        if !errstr.is_null() {
                            width = 0 as libc::c_int;
                        }
                    }
                }
                119 => {
                    modifiers |= 0x1000 as libc::c_int;
                }
                101 => {
                    if !((*fm).argc < 1 as libc::c_int || (*fm).argc > 3 as libc::c_int) {
                        mexp = fm;
                    }
                }
                108 => {
                    modifiers |= 0x10 as libc::c_int;
                }
                97 => {
                    modifiers |= 0x10000 as libc::c_int;
                }
                98 => {
                    modifiers |= 0x2 as libc::c_int;
                }
                99 => {
                    modifiers |= 0x20000 as libc::c_int;
                }
                100 => {
                    modifiers |= 0x4 as libc::c_int;
                }
                110 => {
                    modifiers |= 0x800 as libc::c_int;
                }
                116 => {
                    modifiers |= 0x1 as libc::c_int;
                    if (*fm).argc >= 1 as libc::c_int {
                        if !(strchr(*((*fm).argv).offset(0 as libc::c_int as isize), 'p' as i32))
                            .is_null()
                        {
                            modifiers |= 0x400 as libc::c_int;
                        } else if (*fm).argc >= 2 as libc::c_int
                            && !(strchr(
                                *((*fm).argv).offset(0 as libc::c_int as isize),
                                'f' as i32,
                            ))
                            .is_null()
                        {
                            time_format =
                                format_strip(*((*fm).argv).offset(1 as libc::c_int as isize));
                        }
                    }
                }
                113 => {
                    if (*fm).argc < 1 as libc::c_int {
                        modifiers |= 0x8 as libc::c_int;
                    } else if !(strchr(*((*fm).argv).offset(0 as libc::c_int as isize), 'e' as i32))
                        .is_null()
                        || !(strchr(*((*fm).argv).offset(0 as libc::c_int as isize), 'h' as i32))
                            .is_null()
                    {
                        modifiers |= 0x2000 as libc::c_int;
                    }
                }
                69 => {
                    modifiers |= 0x20 as libc::c_int;
                }
                84 => {
                    modifiers |= 0x40 as libc::c_int;
                }
                78 => {
                    if (*fm).argc < 1 as libc::c_int
                        || !(strchr(*((*fm).argv).offset(0 as libc::c_int as isize), 'w' as i32))
                            .is_null()
                    {
                        modifiers |= 0x4000 as libc::c_int;
                    } else if !(strchr(*((*fm).argv).offset(0 as libc::c_int as isize), 's' as i32))
                        .is_null()
                    {
                        modifiers |= 0x8000 as libc::c_int;
                    }
                }
                83 => {
                    modifiers |= 0x80 as libc::c_int;
                }
                87 => {
                    modifiers |= 0x100 as libc::c_int;
                }
                80 => {
                    modifiers |= 0x200 as libc::c_int;
                }
                76 => {
                    modifiers |= 0x40000 as libc::c_int;
                }
                _ => {}
            }
        } else if (*fm).size == 2 as libc::c_int as libc::c_uint {
            if strcmp(
                ((*fm).modifier).as_mut_ptr(),
                b"||\0" as *const u8 as *const libc::c_char,
            ) == 0 as libc::c_int
                || strcmp(
                    ((*fm).modifier).as_mut_ptr(),
                    b"&&\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                || strcmp(
                    ((*fm).modifier).as_mut_ptr(),
                    b"==\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                || strcmp(
                    ((*fm).modifier).as_mut_ptr(),
                    b"!=\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                || strcmp(
                    ((*fm).modifier).as_mut_ptr(),
                    b">=\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                || strcmp(
                    ((*fm).modifier).as_mut_ptr(),
                    b"<=\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
            {
                cmp = fm;
            }
        }
        i = i.wrapping_add(1);
    }
    if modifiers & 0x10 as libc::c_int != 0 {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"literal string is '%s'\0" as *const u8 as *const libc::c_char,
            copy,
        );
        value = format_unescape(copy);
    } else if modifiers & 0x10000 as libc::c_int != 0 {
        new = format_expand1(es, copy);
        c = strtonum(
            new,
            32 as libc::c_int as libc::c_longlong,
            126 as libc::c_int as libc::c_longlong,
            &mut errstr,
        ) as libc::c_int;
        if !errstr.is_null() {
            value = xstrdup(b"\0" as *const u8 as *const libc::c_char);
        } else {
            xasprintf(
                &mut value as *mut *mut libc::c_char,
                b"%c\0" as *const u8 as *const libc::c_char,
                c,
            );
        }
        free(new as *mut libc::c_void);
    } else if modifiers & 0x20000 as libc::c_int != 0 {
        new = format_expand1(es, copy);
        c = colour_fromstring(new);
        if c == -(1 as libc::c_int) || {
            c = colour_force_rgb(c);
            c == -(1 as libc::c_int)
        } {
            value = xstrdup(b"\0" as *const u8 as *const libc::c_char);
        } else {
            xasprintf(
                &mut value as *mut *mut libc::c_char,
                b"%06x\0" as *const u8 as *const libc::c_char,
                c & 0xffffff as libc::c_int,
            );
        }
        free(new as *mut libc::c_void);
    } else {
        if modifiers & 0x80 as libc::c_int != 0 {
            value = format_loop_sessions(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x100 as libc::c_int != 0 {
            value = format_loop_windows(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x200 as libc::c_int != 0 {
            value = format_loop_panes(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x40000 as libc::c_int != 0 {
            value = format_loop_clients(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x4000 as libc::c_int != 0 {
            value = format_window_name(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x8000 as libc::c_int != 0 {
            value = format_session_name(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if !search.is_null() {
            new = format_expand1(es, copy);
            if wp.is_null() {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"search '%s' but no pane\0" as *const u8 as *const libc::c_char,
                    new,
                );
                value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
            } else {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"search '%s' pane %%%u\0" as *const u8 as *const libc::c_char,
                    new,
                    (*wp).id,
                );
                value = format_search(search, wp, new);
            }
            free(new as *mut libc::c_void);
            current_block = 14584671873312672854;
        } else if !cmp.is_null() {
            if format_choose(es, copy, &mut left, &mut right, 1 as libc::c_int) != 0 as libc::c_int
            {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"compare %s syntax error: %s\0" as *const u8 as *const libc::c_char,
                    ((*cmp).modifier).as_mut_ptr(),
                    copy,
                );
                current_block = 8654942318058171257;
            } else {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"compare %s left is: %s\0" as *const u8 as *const libc::c_char,
                    ((*cmp).modifier).as_mut_ptr(),
                    left,
                );
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"compare %s right is: %s\0" as *const u8 as *const libc::c_char,
                    ((*cmp).modifier).as_mut_ptr(),
                    right,
                );
                if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b"||\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if format_true(left) != 0 || format_true(right) != 0 {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b"&&\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if format_true(left) != 0 && format_true(right) != 0 {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b"==\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if strcmp(left, right) == 0 as libc::c_int {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b"!=\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if strcmp(left, right) != 0 as libc::c_int {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b"<\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if strcmp(left, right) < 0 as libc::c_int {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b">\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if strcmp(left, right) > 0 as libc::c_int {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b"<=\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if strcmp(left, right) <= 0 as libc::c_int {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b">=\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    if strcmp(left, right) >= 0 as libc::c_int {
                        value = xstrdup(b"1\0" as *const u8 as *const libc::c_char);
                    } else {
                        value = xstrdup(b"0\0" as *const u8 as *const libc::c_char);
                    }
                } else if strcmp(
                    ((*cmp).modifier).as_mut_ptr(),
                    b"m\0" as *const u8 as *const libc::c_char,
                ) == 0 as libc::c_int
                {
                    value = format_match(cmp, left, right);
                }
                free(right as *mut libc::c_void);
                free(left as *mut libc::c_void);
                current_block = 14584671873312672854;
            }
        } else if *copy as libc::c_int == '?' as i32 {
            cp = format_skip(
                copy.offset(1 as libc::c_int as isize),
                b",\0" as *const u8 as *const libc::c_char,
            );
            if cp.is_null() {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"condition syntax error: %s\0" as *const u8 as *const libc::c_char,
                    copy.offset(1 as libc::c_int as isize),
                );
                current_block = 8654942318058171257;
            } else {
                condition = xstrndup(
                    copy.offset(1 as libc::c_int as isize),
                    cp.offset_from(copy.offset(1 as libc::c_int as isize)) as libc::c_long
                        as size_t,
                );
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"condition is: %s\0" as *const u8 as *const libc::c_char,
                    condition,
                );
                found = format_find(ft, condition, modifiers, time_format);
                if found.is_null() {
                    found = format_expand1(es, condition);
                    if strcmp(found, condition) == 0 as libc::c_int {
                        free(found as *mut libc::c_void);
                        found = xstrdup(b"\0" as *const u8 as *const libc::c_char);
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                                b"format_replace\0",
                            ))
                            .as_ptr(),
                            b"condition '%s' not found; assuming false\0" as *const u8
                                as *const libc::c_char,
                            condition,
                        );
                    }
                } else {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                            b"format_replace\0",
                        ))
                        .as_ptr(),
                        b"condition '%s' found: %s\0" as *const u8 as *const libc::c_char,
                        condition,
                        found,
                    );
                }
                if format_choose(
                    es,
                    cp.offset(1 as libc::c_int as isize),
                    &mut left,
                    &mut right,
                    0 as libc::c_int,
                ) != 0 as libc::c_int
                {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                            b"format_replace\0",
                        ))
                        .as_ptr(),
                        b"condition '%s' syntax error: %s\0" as *const u8 as *const libc::c_char,
                        condition,
                        cp.offset(1 as libc::c_int as isize),
                    );
                    free(found as *mut libc::c_void);
                    current_block = 8654942318058171257;
                } else {
                    if format_true(found) != 0 {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                                b"format_replace\0",
                            ))
                            .as_ptr(),
                            b"condition '%s' is true\0" as *const u8 as *const libc::c_char,
                            condition,
                        );
                        value = format_expand1(es, left);
                    } else {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                                b"format_replace\0",
                            ))
                            .as_ptr(),
                            b"condition '%s' is false\0" as *const u8 as *const libc::c_char,
                            condition,
                        );
                        value = format_expand1(es, right);
                    }
                    free(right as *mut libc::c_void);
                    free(left as *mut libc::c_void);
                    free(condition as *mut libc::c_void);
                    free(found as *mut libc::c_void);
                    current_block = 14584671873312672854;
                }
            }
        } else {
            if !mexp.is_null() {
                value = format_replace_expression(mexp, es, copy);
                if value.is_null() {
                    value = xstrdup(b"\0" as *const u8 as *const libc::c_char);
                }
            } else if !(strstr(copy, b"#{\0" as *const u8 as *const libc::c_char)).is_null() {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"expanding inner format '%s'\0" as *const u8 as *const libc::c_char,
                    copy,
                );
                value = format_expand1(es, copy);
            } else {
                value = format_find(ft, copy, modifiers, time_format);
                if value.is_null() {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                            b"format_replace\0",
                        ))
                        .as_ptr(),
                        b"format '%s' not found\0" as *const u8 as *const libc::c_char,
                        copy,
                    );
                    value = xstrdup(b"\0" as *const u8 as *const libc::c_char);
                } else {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                            b"format_replace\0",
                        ))
                        .as_ptr(),
                        b"format '%s' found: %s\0" as *const u8 as *const libc::c_char,
                        copy,
                        value,
                    );
                }
            }
            current_block = 14584671873312672854;
        }
        match current_block {
            14584671873312672854 => {}
            _ => {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                        b"format_replace\0",
                    ))
                    .as_ptr(),
                    b"failed %s\0" as *const u8 as *const libc::c_char,
                    copy0,
                );
                free(sub as *mut libc::c_void);
                format_free_modifiers(list, count);
                free(copy0 as *mut libc::c_void);
                return -(1 as libc::c_int);
            }
        }
    }
    if modifiers & 0x20 as libc::c_int != 0 {
        new = format_expand1(es, value);
        free(value as *mut libc::c_void);
        value = new;
    } else if modifiers & 0x40 as libc::c_int != 0 {
        format_copy_state(&mut next, es, 0x1 as libc::c_int);
        new = format_expand1(&mut next, value);
        free(value as *mut libc::c_void);
        value = new;
    }
    i = 0 as libc::c_int as u_int;
    while i < nsub {
        left = format_expand1(
            es,
            *((**sub.offset(i as isize)).argv).offset(0 as libc::c_int as isize),
        );
        right = format_expand1(
            es,
            *((**sub.offset(i as isize)).argv).offset(1 as libc::c_int as isize),
        );
        new = format_sub(*sub.offset(i as isize), value, left, right);
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"substitute '%s' to '%s': %s\0" as *const u8 as *const libc::c_char,
            left,
            right,
            new,
        );
        free(value as *mut libc::c_void);
        value = new;
        free(right as *mut libc::c_void);
        free(left as *mut libc::c_void);
        i = i.wrapping_add(1);
    }
    if limit > 0 as libc::c_int {
        new = format_trim_left(value, limit as u_int);
        if !marker.is_null() && strcmp(new, value) != 0 as libc::c_int {
            free(value as *mut libc::c_void);
            xasprintf(
                &mut value as *mut *mut libc::c_char,
                b"%s%s\0" as *const u8 as *const libc::c_char,
                new,
                marker,
            );
        } else {
            free(value as *mut libc::c_void);
            value = new;
        }
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"applied length limit %d: %s\0" as *const u8 as *const libc::c_char,
            limit,
            value,
        );
    } else if limit < 0 as libc::c_int {
        new = format_trim_right(value, -limit as u_int);
        if !marker.is_null() && strcmp(new, value) != 0 as libc::c_int {
            free(value as *mut libc::c_void);
            xasprintf(
                &mut value as *mut *mut libc::c_char,
                b"%s%s\0" as *const u8 as *const libc::c_char,
                marker,
                new,
            );
        } else {
            free(value as *mut libc::c_void);
            value = new;
        }
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"applied length limit %d: %s\0" as *const u8 as *const libc::c_char,
            limit,
            value,
        );
    }
    if width > 0 as libc::c_int {
        new = utf8_padcstr(value, width as u_int);
        free(value as *mut libc::c_void);
        value = new;
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"applied padding width %d: %s\0" as *const u8 as *const libc::c_char,
            width,
            value,
        );
    } else if width < 0 as libc::c_int {
        new = utf8_rpadcstr(value, -width as u_int);
        free(value as *mut libc::c_void);
        value = new;
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"applied padding width %d: %s\0" as *const u8 as *const libc::c_char,
            width,
            value,
        );
    }
    if modifiers & 0x800 as libc::c_int != 0 {
        xasprintf(
            &mut new as *mut *mut libc::c_char,
            b"%zu\0" as *const u8 as *const libc::c_char,
            strlen(value),
        );
        free(value as *mut libc::c_void);
        value = new;
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"replacing with length: %s\0" as *const u8 as *const libc::c_char,
            new,
        );
    }
    if modifiers & 0x1000 as libc::c_int != 0 {
        xasprintf(
            &mut new as *mut *mut libc::c_char,
            b"%u\0" as *const u8 as *const libc::c_char,
            format_width(value),
        );
        free(value as *mut libc::c_void);
        value = new;
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0"))
                .as_ptr(),
            b"replacing with width: %s\0" as *const u8 as *const libc::c_char,
            new,
        );
    }
    valuelen = strlen(value);
    while (*len).wrapping_sub(*off) < valuelen.wrapping_add(1 as libc::c_int as libc::c_ulong) {
        *buf = xreallocarray(*buf as *mut libc::c_void, 2 as libc::c_int as size_t, *len)
            as *mut libc::c_char;
        *len = (*len as libc::c_ulong).wrapping_mul(2 as libc::c_int as libc::c_ulong) as size_t
            as size_t;
    }
    memcpy(
        (*buf).offset(*off as isize) as *mut libc::c_void,
        value as *const libc::c_void,
        valuelen,
    );
    *off = (*off as libc::c_ulong).wrapping_add(valuelen) as size_t as size_t;
    format_log1(
        es,
        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_replace\0")).as_ptr(),
        b"replaced '%s' with '%s'\0" as *const u8 as *const libc::c_char,
        copy0,
        value,
    );
    free(value as *mut libc::c_void);
    free(sub as *mut libc::c_void);
    format_free_modifiers(list, count);
    free(copy0 as *mut libc::c_void);
    return 0 as libc::c_int;
}
unsafe extern "C" fn format_expand1(
    mut es: *mut format_expand_state,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = (*es).ft;
    let mut buf: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut out: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut name: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut ptr: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut s: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut style_end: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut off: size_t = 0;
    let mut len: size_t = 0;
    let mut n: size_t = 0;
    let mut outlen: size_t = 0;
    let mut ch: libc::c_int = 0;
    let mut brackets: libc::c_int = 0;
    let mut expanded: [libc::c_char; 8192] = [0; 8192];
    if fmt.is_null() || *fmt as libc::c_int == '\0' as i32 {
        return xstrdup(b"\0" as *const u8 as *const libc::c_char);
    }
    if (*es).loop_0 == 100 as libc::c_int as libc::c_uint {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_expand1\0"))
                .as_ptr(),
            b"reached loop limit (%u)\0" as *const u8 as *const libc::c_char,
            100 as libc::c_int,
        );
        return xstrdup(b"\0" as *const u8 as *const libc::c_char);
    }
    (*es).loop_0 = ((*es).loop_0).wrapping_add(1);
    format_log1(
        es,
        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_expand1\0")).as_ptr(),
        b"expanding format: %s\0" as *const u8 as *const libc::c_char,
        fmt,
    );
    if (*es).flags & 0x1 as libc::c_int != 0 && !(strchr(fmt, '%' as i32)).is_null() {
        if (*es).time == 0 as libc::c_int as libc::c_long {
            (*es).time = time(std::ptr::null_mut::<time_t>());
            localtime_r(&mut (*es).time, &mut (*es).tm);
        }
        if strftime(
            expanded.as_mut_ptr(),
            ::core::mem::size_of::<[libc::c_char; 8192]>() as libc::c_ulong,
            fmt,
            &mut (*es).tm,
        ) == 0 as libc::c_int as libc::c_ulong
        {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_expand1\0"))
                    .as_ptr(),
                b"format is too long\0" as *const u8 as *const libc::c_char,
            );
            return xstrdup(b"\0" as *const u8 as *const libc::c_char);
        }
        if format_logging(ft) != 0 && strcmp(expanded.as_mut_ptr(), fmt) != 0 as libc::c_int {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_expand1\0"))
                    .as_ptr(),
                b"after time expanded: %s\0" as *const u8 as *const libc::c_char,
                expanded.as_mut_ptr(),
            );
        }
        fmt = expanded.as_mut_ptr();
    }
    len = 64 as libc::c_int as size_t;
    buf = xmalloc(len) as *mut libc::c_char;
    off = 0 as libc::c_int as size_t;
    while *fmt as libc::c_int != '\0' as i32 {
        if *fmt as libc::c_int != '#' as i32 {
            while len.wrapping_sub(off) < 2 as libc::c_int as libc::c_ulong {
                buf = xreallocarray(buf as *mut libc::c_void, 2 as libc::c_int as size_t, len)
                    as *mut libc::c_char;
                len = (len as libc::c_ulong).wrapping_mul(2 as libc::c_int as libc::c_ulong)
                    as size_t as size_t;
            }
            let fresh14 = fmt;
            fmt = fmt.offset(1);
            let fresh15 = off;
            off = off.wrapping_add(1);
            *buf.offset(fresh15 as isize) = *fresh14;
        } else {
            fmt = fmt.offset(1);
            let fresh16 = fmt;
            fmt = fmt.offset(1);
            ch = *fresh16 as u_char as libc::c_int;
            match ch {
                40 => {
                    brackets = 1 as libc::c_int;
                    ptr = fmt;
                    while *ptr as libc::c_int != '\0' as i32 {
                        if *ptr as libc::c_int == '(' as i32 {
                            brackets += 1;
                        }
                        if *ptr as libc::c_int == ')' as i32 && {
                            brackets -= 1;
                            brackets == 0 as libc::c_int
                        } {
                            break;
                        }
                        ptr = ptr.offset(1);
                    }
                    if *ptr as libc::c_int != ')' as i32 || brackets != 0 as libc::c_int {
                        break;
                    }
                    n = ptr.offset_from(fmt) as libc::c_long as size_t;
                    name = xstrndup(fmt, n);
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                            b"format_expand1\0",
                        ))
                        .as_ptr(),
                        b"found #(): %s\0" as *const u8 as *const libc::c_char,
                        name,
                    );
                    if (*ft).flags & 0x4 as libc::c_int != 0
                        || (*es).flags & 0x2 as libc::c_int != 0
                    {
                        out = xstrdup(b"\0" as *const u8 as *const libc::c_char);
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                                b"format_expand1\0",
                            ))
                            .as_ptr(),
                            b"#() is disabled\0" as *const u8 as *const libc::c_char,
                        );
                    } else {
                        out = format_job_get(es, name);
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                                b"format_expand1\0",
                            ))
                            .as_ptr(),
                            b"#() result: %s\0" as *const u8 as *const libc::c_char,
                            out,
                        );
                    }
                    free(name as *mut libc::c_void);
                    outlen = strlen(out);
                    while len.wrapping_sub(off)
                        < outlen.wrapping_add(1 as libc::c_int as libc::c_ulong)
                    {
                        buf = xreallocarray(
                            buf as *mut libc::c_void,
                            2 as libc::c_int as size_t,
                            len,
                        ) as *mut libc::c_char;
                        len = (len as libc::c_ulong).wrapping_mul(2 as libc::c_int as libc::c_ulong)
                            as size_t as size_t;
                    }
                    memcpy(
                        buf.offset(off as isize) as *mut libc::c_void,
                        out as *const libc::c_void,
                        outlen,
                    );
                    off = (off as libc::c_ulong).wrapping_add(outlen) as size_t as size_t;
                    free(out as *mut libc::c_void);
                    fmt = fmt.offset(n.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize);
                    continue;
                }
                123 => {
                    ptr = format_skip(
                        (fmt as *mut libc::c_char).offset(-(2 as libc::c_int as isize)),
                        b"}\0" as *const u8 as *const libc::c_char,
                    );
                    if ptr.is_null() {
                        break;
                    }
                    n = ptr.offset_from(fmt) as libc::c_long as size_t;
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                            b"format_expand1\0",
                        ))
                        .as_ptr(),
                        b"found #{}: %.*s\0" as *const u8 as *const libc::c_char,
                        n as libc::c_int,
                        fmt,
                    );
                    if format_replace(es, fmt, n, &mut buf, &mut len, &mut off) != 0 as libc::c_int
                    {
                        break;
                    }
                    fmt = fmt.offset(n.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize);
                    continue;
                }
                91 | 35 => {
                    ptr = fmt.offset(-((ch == '[' as i32) as libc::c_int as isize));
                    n = (2 as libc::c_int - (ch == '[' as i32) as libc::c_int) as size_t;
                    while *ptr as libc::c_int == '#' as i32 {
                        ptr = ptr.offset(1);
                        n = n.wrapping_add(1);
                    }
                    if *ptr as libc::c_int == '[' as i32 {
                        style_end = format_skip(
                            fmt.offset(-(2 as libc::c_int as isize)),
                            b"]\0" as *const u8 as *const libc::c_char,
                        );
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                                b"format_expand1\0",
                            ))
                            .as_ptr(),
                            b"found #*%zu[\0" as *const u8 as *const libc::c_char,
                            n,
                        );
                        while len.wrapping_sub(off)
                            < n.wrapping_add(2 as libc::c_int as libc::c_ulong)
                        {
                            buf = xreallocarray(
                                buf as *mut libc::c_void,
                                2 as libc::c_int as size_t,
                                len,
                            ) as *mut libc::c_char;
                            len = (len as libc::c_ulong)
                                .wrapping_mul(2 as libc::c_int as libc::c_ulong)
                                as size_t as size_t;
                        }
                        memcpy(
                            buf.offset(off as isize) as *mut libc::c_void,
                            fmt.offset(-(2 as libc::c_int as isize)) as *const libc::c_void,
                            n.wrapping_add(1 as libc::c_int as libc::c_ulong),
                        );
                        off = (off as libc::c_ulong)
                            .wrapping_add(n.wrapping_add(1 as libc::c_int as libc::c_ulong))
                            as size_t as size_t;
                        fmt = ptr.offset(1 as libc::c_int as isize);
                        continue;
                    }
                }
                125 | 44 => {}
                _ => {
                    s = std::ptr::null::<libc::c_char>();
                    if fmt > style_end {
                        if ch >= 'A' as i32 && ch <= 'Z' as i32 {
                            s = format_upper[(ch - 'A' as i32) as usize];
                        } else if ch >= 'a' as i32 && ch <= 'z' as i32 {
                            s = format_lower[(ch - 'a' as i32) as usize];
                        }
                    }
                    if s.is_null() {
                        while len.wrapping_sub(off) < 3 as libc::c_int as libc::c_ulong {
                            buf = xreallocarray(
                                buf as *mut libc::c_void,
                                2 as libc::c_int as size_t,
                                len,
                            ) as *mut libc::c_char;
                            len = (len as libc::c_ulong)
                                .wrapping_mul(2 as libc::c_int as libc::c_ulong)
                                as size_t as size_t;
                        }
                        let fresh18 = off;
                        off = off.wrapping_add(1);
                        *buf.offset(fresh18 as isize) = '#' as i32 as libc::c_char;
                        let fresh19 = off;
                        off = off.wrapping_add(1);
                        *buf.offset(fresh19 as isize) = ch as libc::c_char;
                        continue;
                    } else {
                        n = strlen(s);
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(
                                b"format_expand1\0",
                            ))
                            .as_ptr(),
                            b"found #%c: %s\0" as *const u8 as *const libc::c_char,
                            ch,
                            s,
                        );
                        if format_replace(es, s, n, &mut buf, &mut len, &mut off)
                            != 0 as libc::c_int
                        {
                            break;
                        } else {
                            continue;
                        }
                    }
                }
            }
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_expand1\0"))
                    .as_ptr(),
                b"found #%c\0" as *const u8 as *const libc::c_char,
                ch,
            );
            while len.wrapping_sub(off) < 2 as libc::c_int as libc::c_ulong {
                buf = xreallocarray(buf as *mut libc::c_void, 2 as libc::c_int as size_t, len)
                    as *mut libc::c_char;
                len = (len as libc::c_ulong).wrapping_mul(2 as libc::c_int as libc::c_ulong)
                    as size_t as size_t;
            }
            let fresh17 = off;
            off = off.wrapping_add(1);
            *buf.offset(fresh17 as isize) = ch as libc::c_char;
        }
    }
    *buf.offset(off as isize) = '\0' as i32 as libc::c_char;
    format_log1(
        es,
        (*::core::mem::transmute::<&[u8; 15], &[libc::c_char; 15]>(b"format_expand1\0")).as_ptr(),
        b"result is: %s\0" as *const u8 as *const libc::c_char,
        buf,
    );
    (*es).loop_0 = ((*es).loop_0).wrapping_sub(1);
    return buf;
}
#[no_mangle]
pub unsafe extern "C" fn format_expand_time(
    mut ft: *mut format_tree,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut es: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    memset(
        &mut es as *mut format_expand_state as *mut libc::c_void,
        0 as libc::c_int,
        ::core::mem::size_of::<format_expand_state>() as libc::c_ulong,
    );
    es.ft = ft;
    es.flags = 0x1 as libc::c_int;
    return format_expand1(&mut es, fmt);
}
#[no_mangle]
pub unsafe extern "C" fn format_expand(
    mut ft: *mut format_tree,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut es: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<libc::c_char>(),
        },
        flags: 0,
    };
    memset(
        &mut es as *mut format_expand_state as *mut libc::c_void,
        0 as libc::c_int,
        ::core::mem::size_of::<format_expand_state>() as libc::c_ulong,
    );
    es.ft = ft;
    es.flags = 0 as libc::c_int;
    return format_expand1(&mut es, fmt);
}
#[no_mangle]
pub unsafe extern "C" fn format_single(
    mut item: *mut cmdq_item,
    mut fmt: *const libc::c_char,
    mut c: *mut client,
    mut s: *mut session,
    mut wl: *mut winlink,
    mut wp: *mut window_pane,
) -> *mut libc::c_char {
    let mut ft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut expanded: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    ft = format_create_defaults(item, c, s, wl, wp);
    expanded = format_expand(ft, fmt);
    format_free(ft);
    return expanded;
}
#[no_mangle]
pub unsafe extern "C" fn format_single_from_state(
    mut item: *mut cmdq_item,
    mut fmt: *const libc::c_char,
    mut c: *mut client,
    mut fs: *mut cmd_find_state,
) -> *mut libc::c_char {
    return format_single(item, fmt, c, (*fs).s, (*fs).wl, (*fs).wp);
}
#[no_mangle]
pub unsafe extern "C" fn format_single_from_target(
    mut item: *mut cmdq_item,
    mut fmt: *const libc::c_char,
) -> *mut libc::c_char {
    let mut tc: *mut client = cmdq_get_target_client(item);
    return format_single_from_state(item, fmt, tc, cmdq_get_target(item));
}
#[no_mangle]
pub unsafe extern "C" fn format_create_defaults(
    mut item: *mut cmdq_item,
    mut c: *mut client,
    mut s: *mut session,
    mut wl: *mut winlink,
    mut wp: *mut window_pane,
) -> *mut format_tree {
    let mut ft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    if !item.is_null() {
        ft = format_create(
            cmdq_get_client(item),
            item,
            0 as libc::c_int,
            0 as libc::c_int,
        );
    } else {
        ft = format_create(
            std::ptr::null_mut::<client>(),
            item,
            0 as libc::c_int,
            0 as libc::c_int,
        );
    }
    format_defaults(ft, c, s, wl, wp);
    return ft;
}
#[no_mangle]
pub unsafe extern "C" fn format_create_from_state(
    mut item: *mut cmdq_item,
    mut c: *mut client,
    mut fs: *mut cmd_find_state,
) -> *mut format_tree {
    return format_create_defaults(item, c, (*fs).s, (*fs).wl, (*fs).wp);
}
#[no_mangle]
pub unsafe extern "C" fn format_create_from_target(mut item: *mut cmdq_item) -> *mut format_tree {
    let mut tc: *mut client = cmdq_get_target_client(item);
    return format_create_from_state(item, tc, cmdq_get_target(item));
}
#[no_mangle]
pub unsafe extern "C" fn format_defaults(
    mut ft: *mut format_tree,
    mut c: *mut client,
    mut s: *mut session,
    mut wl: *mut winlink,
    mut wp: *mut window_pane,
) {
    let mut pb: *mut paste_buffer = std::ptr::null_mut::<paste_buffer>();
    if !c.is_null() && !((*c).name).is_null() {
        log_debug(
            b"%s: c=%s\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
            (*c).name,
        );
    } else {
        log_debug(
            b"%s: c=none\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
        );
    }
    if !s.is_null() {
        log_debug(
            b"%s: s=$%u\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
            (*s).id,
        );
    } else {
        log_debug(
            b"%s: s=none\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
        );
    }
    if !wl.is_null() {
        log_debug(
            b"%s: wl=%u\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
            (*wl).idx,
        );
    } else {
        log_debug(
            b"%s: wl=none\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
        );
    }
    if !wp.is_null() {
        log_debug(
            b"%s: wp=%%%u\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
            (*wp).id,
        );
    } else {
        log_debug(
            b"%s: wp=none\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
        );
    }
    if !c.is_null() && !s.is_null() && (*c).session != s {
        log_debug(
            b"%s: session does not match\0" as *const u8 as *const libc::c_char,
            (*::core::mem::transmute::<&[u8; 16], &[libc::c_char; 16]>(b"format_defaults\0"))
                .as_ptr(),
        );
    }
    if !wp.is_null() {
        (*ft).type_0 = FORMAT_TYPE_PANE;
    } else if !wl.is_null() {
        (*ft).type_0 = FORMAT_TYPE_WINDOW;
    } else if !s.is_null() {
        (*ft).type_0 = FORMAT_TYPE_SESSION;
    } else {
        (*ft).type_0 = FORMAT_TYPE_UNKNOWN;
    }
    if s.is_null() && !c.is_null() {
        s = (*c).session;
    }
    if wl.is_null() && !s.is_null() {
        wl = (*s).curw;
    }
    if wp.is_null() && !wl.is_null() {
        wp = (*(*wl).window).active;
    }
    if !c.is_null() {
        format_defaults_client(ft, c);
    }
    if !s.is_null() {
        format_defaults_session(ft, s);
    }
    if !wl.is_null() {
        format_defaults_winlink(ft, wl);
    }
    if !wp.is_null() {
        format_defaults_pane(ft, wp);
    }
    pb = paste_get_top(std::ptr::null_mut::<*const libc::c_char>());
    if !pb.is_null() {
        format_defaults_paste_buffer(ft, pb);
    }
}
unsafe extern "C" fn format_defaults_session(mut ft: *mut format_tree, mut s: *mut session) {
    (*ft).s = s;
}
unsafe extern "C" fn format_defaults_client(mut ft: *mut format_tree, mut c: *mut client) {
    if ((*ft).s).is_null() {
        (*ft).s = (*c).session;
    }
    (*ft).c = c;
}
#[no_mangle]
pub unsafe extern "C" fn format_defaults_window(mut ft: *mut format_tree, mut w: *mut window) {
    (*ft).w = w;
}
unsafe extern "C" fn format_defaults_winlink(mut ft: *mut format_tree, mut wl: *mut winlink) {
    if ((*ft).w).is_null() {
        format_defaults_window(ft, (*wl).window);
    }
    (*ft).wl = wl;
}
#[no_mangle]
pub unsafe extern "C" fn format_defaults_pane(mut ft: *mut format_tree, mut wp: *mut window_pane) {
    let mut wme: *mut window_mode_entry = std::ptr::null_mut::<window_mode_entry>();
    if ((*ft).w).is_null() {
        format_defaults_window(ft, (*wp).window);
    }
    (*ft).wp = wp;
    wme = (*wp).modes.tqh_first;
    if !wme.is_null() && ((*(*wme).mode).formats).is_some() {
        ((*(*wme).mode).formats).expect("non-null function pointer")(wme, ft);
    }
}
#[no_mangle]
pub unsafe extern "C" fn format_defaults_paste_buffer(
    mut ft: *mut format_tree,
    mut pb: *mut paste_buffer,
) {
    (*ft).pb = pb;
}
unsafe extern "C" fn format_is_word_separator(
    mut ws: *const libc::c_char,
    mut gc: *const grid_cell,
) -> libc::c_int {
    if utf8_cstrhas(ws, &(*gc).data) != 0 {
        return 1 as libc::c_int;
    }
    if (*gc).flags as libc::c_int & 0x80 as libc::c_int != 0 {
        return 1 as libc::c_int;
    }
    return ((*gc).data.size as libc::c_int == 1 as libc::c_int
        && *((*gc).data.data).as_ptr() as libc::c_int == ' ' as i32) as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn format_grid_word(
    mut gd: *mut grid,
    mut x: u_int,
    mut y: u_int,
) -> *mut libc::c_char {
    let mut gl: *const grid_line = std::ptr::null::<grid_line>();
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut ws: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut ud: *mut utf8_data = std::ptr::null_mut::<utf8_data>();
    let mut end: u_int = 0;
    let mut size: size_t = 0 as libc::c_int as size_t;
    let mut found: libc::c_int = 0 as libc::c_int;
    let mut s: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    ws = options_get_string(
        global_s_options,
        b"word-separators\0" as *const u8 as *const libc::c_char,
    );
    loop {
        grid_get_cell(gd, x, y, &mut gc);
        if gc.flags as libc::c_int & 0x4 as libc::c_int != 0 {
            break;
        }
        if format_is_word_separator(ws, &mut gc) != 0 {
            found = 1 as libc::c_int;
            break;
        } else {
            if x == 0 as libc::c_int as libc::c_uint {
                if y == 0 as libc::c_int as libc::c_uint {
                    break;
                }
                gl = grid_peek_line(gd, y.wrapping_sub(1 as libc::c_int as libc::c_uint));
                if !(*gl).flags & 0x1 as libc::c_int != 0 {
                    break;
                }
                y = y.wrapping_sub(1);
                x = grid_line_length(gd, y);
                if x == 0 as libc::c_int as libc::c_uint {
                    break;
                }
            }
            x = x.wrapping_sub(1);
        }
    }
    loop {
        if found != 0 {
            end = grid_line_length(gd, y);
            if end == 0 as libc::c_int as libc::c_uint
                || x == end.wrapping_sub(1 as libc::c_int as libc::c_uint)
            {
                if y == ((*gd).hsize)
                    .wrapping_add((*gd).sy)
                    .wrapping_sub(1 as libc::c_int as libc::c_uint)
                {
                    break;
                }
                gl = grid_peek_line(gd, y);
                if !(*gl).flags & 0x1 as libc::c_int != 0 {
                    break;
                }
                y = y.wrapping_add(1);
                x = 0 as libc::c_int as u_int;
            } else {
                x = x.wrapping_add(1);
            }
        }
        found = 1 as libc::c_int;
        grid_get_cell(gd, x, y, &mut gc);
        if gc.flags as libc::c_int & 0x4 as libc::c_int != 0 {
            break;
        }
        if format_is_word_separator(ws, &mut gc) != 0 {
            break;
        }
        ud = xreallocarray(
            ud as *mut libc::c_void,
            size.wrapping_add(2 as libc::c_int as libc::c_ulong),
            ::core::mem::size_of::<utf8_data>() as libc::c_ulong,
        ) as *mut utf8_data;
        let fresh20 = size;
        size = size.wrapping_add(1);
        memcpy(
            &mut *ud.offset(fresh20 as isize) as *mut utf8_data as *mut libc::c_void,
            &mut gc.data as *mut utf8_data as *const libc::c_void,
            ::core::mem::size_of::<utf8_data>() as libc::c_ulong,
        );
    }
    if size != 0 as libc::c_int as libc::c_ulong {
        (*ud.offset(size as isize)).size = 0 as libc::c_int as u_char;
        s = utf8_tocstr(ud);
        free(ud as *mut libc::c_void);
    }
    return s;
}
#[no_mangle]
pub unsafe extern "C" fn format_grid_line(mut gd: *mut grid, mut y: u_int) -> *mut libc::c_char {
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut ud: *mut utf8_data = std::ptr::null_mut::<utf8_data>();
    let mut x: u_int = 0;
    let mut size: size_t = 0 as libc::c_int as size_t;
    let mut s: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    x = 0 as libc::c_int as u_int;
    while x < grid_line_length(gd, y) {
        grid_get_cell(gd, x, y, &mut gc);
        if gc.flags as libc::c_int & 0x4 as libc::c_int == 0 {
            ud = xreallocarray(
                ud as *mut libc::c_void,
                size.wrapping_add(2 as libc::c_int as libc::c_ulong),
                ::core::mem::size_of::<utf8_data>() as libc::c_ulong,
            ) as *mut utf8_data;
            if gc.flags as libc::c_int & 0x80 as libc::c_int != 0 {
                let fresh21 = size;
                size = size.wrapping_add(1);
                utf8_set(&mut *ud.offset(fresh21 as isize), '\t' as i32 as u_char);
            } else {
                let fresh22 = size;
                size = size.wrapping_add(1);
                memcpy(
                    &mut *ud.offset(fresh22 as isize) as *mut utf8_data as *mut libc::c_void,
                    &mut gc.data as *mut utf8_data as *const libc::c_void,
                    ::core::mem::size_of::<utf8_data>() as libc::c_ulong,
                );
            }
        }
        x = x.wrapping_add(1);
    }
    if size != 0 as libc::c_int as libc::c_ulong {
        (*ud.offset(size as isize)).size = 0 as libc::c_int as u_char;
        s = utf8_tocstr(ud);
        free(ud as *mut libc::c_void);
    }
    return s;
}
#[no_mangle]
pub unsafe extern "C" fn format_grid_hyperlink(
    mut gd: *mut grid,
    mut x: u_int,
    mut y: u_int,
    mut s: *mut screen,
) -> *mut libc::c_char {
    let mut uri: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    grid_get_cell(gd, x, y, &mut gc);
    if gc.flags as libc::c_int & 0x4 as libc::c_int != 0 {
        return std::ptr::null_mut::<libc::c_char>();
    }
    if ((*s).hyperlinks).is_null() || gc.link == 0 as libc::c_int as libc::c_uint {
        return std::ptr::null_mut::<libc::c_char>();
    }
    if hyperlinks_get(
        (*s).hyperlinks,
        gc.link,
        &mut uri,
        std::ptr::null_mut::<*const libc::c_char>(),
        std::ptr::null_mut::<*const libc::c_char>(),
    ) == 0
    {
        return std::ptr::null_mut::<libc::c_char>();
    }
    return xstrdup(uri);
}
